1 /*******************************************************************************
3 Copyright (c) 2001-2015, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 3. Neither the name of the Intel Corporation nor the names of its
17 contributors may be used to endorse or promote products derived from
18 this software without specific prior written permission.
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 POSSIBILITY OF SUCH DAMAGE.
32 ***************************************************************************/
34 #include "ixgbe_x550.h"
35 #include "ixgbe_x540.h"
36 #include "ixgbe_type.h"
37 #include "ixgbe_api.h"
38 #include "ixgbe_common.h"
39 #include "ixgbe_phy.h"
41 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed);
42 static s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
43 static void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
46 * ixgbe_init_ops_X550 - Inits func ptrs and MAC type
47 * @hw: pointer to hardware structure
49 * Initialize the function pointers and assign the MAC type for X550.
50 * Does not touch the hardware.
52 s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
54 struct ixgbe_mac_info *mac = &hw->mac;
55 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
58 DEBUGFUNC("ixgbe_init_ops_X550");
60 ret_val = ixgbe_init_ops_X540(hw);
61 mac->ops.dmac_config = ixgbe_dmac_config_X550;
62 mac->ops.dmac_config_tcs = ixgbe_dmac_config_tcs_X550;
63 mac->ops.dmac_update_tcs = ixgbe_dmac_update_tcs_X550;
64 mac->ops.setup_eee = ixgbe_setup_eee_X550;
65 mac->ops.set_source_address_pruning =
66 ixgbe_set_source_address_pruning_X550;
67 mac->ops.set_ethertype_anti_spoofing =
68 ixgbe_set_ethertype_anti_spoofing_X550;
70 mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
71 eeprom->ops.init_params = ixgbe_init_eeprom_params_X550;
72 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
73 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
74 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
75 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
76 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
77 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
78 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
80 mac->ops.disable_mdd = ixgbe_disable_mdd_X550;
81 mac->ops.enable_mdd = ixgbe_enable_mdd_X550;
82 mac->ops.mdd_event = ixgbe_mdd_event_X550;
83 mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
84 mac->ops.disable_rx = ixgbe_disable_rx_x550;
85 switch (hw->device_id) {
86 case IXGBE_DEV_ID_X550EM_X_10G_T:
87 case IXGBE_DEV_ID_X550EM_A_10G_T:
88 hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
89 hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
98 * ixgbe_read_cs4227 - Read CS4227 register
99 * @hw: pointer to hardware structure
100 * @reg: register number to write
101 * @value: pointer to receive value read
103 * Returns status code
105 STATIC s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
107 return hw->link.ops.read_link_unlocked(hw, hw->link.addr, reg, value);
111 * ixgbe_write_cs4227 - Write CS4227 register
112 * @hw: pointer to hardware structure
113 * @reg: register number to write
114 * @value: value to write to register
116 * Returns status code
118 STATIC s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
120 return hw->link.ops.write_link_unlocked(hw, hw->link.addr, reg, value);
124 * ixgbe_read_pe - Read register from port expander
125 * @hw: pointer to hardware structure
126 * @reg: register number to read
127 * @value: pointer to receive read value
129 * Returns status code
131 STATIC s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
135 status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
136 if (status != IXGBE_SUCCESS)
137 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
138 "port expander access failed with %d\n", status);
143 * ixgbe_write_pe - Write register to port expander
144 * @hw: pointer to hardware structure
145 * @reg: register number to write
146 * @value: value to write
148 * Returns status code
150 STATIC s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
154 status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
155 if (status != IXGBE_SUCCESS)
156 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
157 "port expander access failed with %d\n", status);
162 * ixgbe_reset_cs4227 - Reset CS4227 using port expander
163 * @hw: pointer to hardware structure
165 * This function assumes that the caller has acquired the proper semaphore.
168 STATIC s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
175 /* Trigger hard reset. */
176 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
177 if (status != IXGBE_SUCCESS)
179 reg |= IXGBE_PE_BIT1;
180 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
181 if (status != IXGBE_SUCCESS)
184 status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, ®);
185 if (status != IXGBE_SUCCESS)
187 reg &= ~IXGBE_PE_BIT1;
188 status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
189 if (status != IXGBE_SUCCESS)
192 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
193 if (status != IXGBE_SUCCESS)
195 reg &= ~IXGBE_PE_BIT1;
196 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
197 if (status != IXGBE_SUCCESS)
200 usec_delay(IXGBE_CS4227_RESET_HOLD);
202 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
203 if (status != IXGBE_SUCCESS)
205 reg |= IXGBE_PE_BIT1;
206 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
207 if (status != IXGBE_SUCCESS)
210 /* Wait for the reset to complete. */
211 msec_delay(IXGBE_CS4227_RESET_DELAY);
212 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
213 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EFUSE_STATUS,
215 if (status == IXGBE_SUCCESS &&
216 value == IXGBE_CS4227_EEPROM_LOAD_OK)
218 msec_delay(IXGBE_CS4227_CHECK_DELAY);
220 if (retry == IXGBE_CS4227_RETRIES) {
221 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
222 "CS4227 reset did not complete.");
223 return IXGBE_ERR_PHY;
226 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EEPROM_STATUS, &value);
227 if (status != IXGBE_SUCCESS ||
228 !(value & IXGBE_CS4227_EEPROM_LOAD_OK)) {
229 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
230 "CS4227 EEPROM did not load successfully.");
231 return IXGBE_ERR_PHY;
234 return IXGBE_SUCCESS;
238 * ixgbe_check_cs4227 - Check CS4227 and reset as needed
239 * @hw: pointer to hardware structure
241 STATIC void ixgbe_check_cs4227(struct ixgbe_hw *hw)
243 s32 status = IXGBE_SUCCESS;
244 u32 swfw_mask = hw->phy.phy_semaphore_mask;
248 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
249 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
250 if (status != IXGBE_SUCCESS) {
251 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
252 "semaphore failed with %d", status);
253 msec_delay(IXGBE_CS4227_CHECK_DELAY);
257 /* Get status of reset flow. */
258 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
260 if (status == IXGBE_SUCCESS &&
261 value == IXGBE_CS4227_RESET_COMPLETE)
264 if (status != IXGBE_SUCCESS ||
265 value != IXGBE_CS4227_RESET_PENDING)
268 /* Reset is pending. Wait and check again. */
269 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
270 msec_delay(IXGBE_CS4227_CHECK_DELAY);
273 /* If still pending, assume other instance failed. */
274 if (retry == IXGBE_CS4227_RETRIES) {
275 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
276 if (status != IXGBE_SUCCESS) {
277 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
278 "semaphore failed with %d", status);
283 /* Reset the CS4227. */
284 status = ixgbe_reset_cs4227(hw);
285 if (status != IXGBE_SUCCESS) {
286 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
287 "CS4227 reset failed: %d", status);
291 /* Reset takes so long, temporarily release semaphore in case the
292 * other driver instance is waiting for the reset indication.
294 ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
295 IXGBE_CS4227_RESET_PENDING);
296 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
298 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
299 if (status != IXGBE_SUCCESS) {
300 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
301 "semaphore failed with %d", status);
305 /* Record completion for next time. */
306 status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
307 IXGBE_CS4227_RESET_COMPLETE);
310 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
311 msec_delay(hw->eeprom.semaphore_delay);
315 * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
316 * @hw: pointer to hardware structure
318 STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
320 u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
322 if (hw->bus.lan_id) {
323 esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
324 esdp |= IXGBE_ESDP_SDP1_DIR;
326 esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
327 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
328 IXGBE_WRITE_FLUSH(hw);
332 * ixgbe_identify_phy_1g - Get 1g PHY type based on device id
333 * @hw: pointer to hardware structure
337 static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
343 val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
344 hw->phy.addr, &phy_id_high);
345 if (val || phy_id_high == 0xFFFF) {
346 hw->phy.type = ixgbe_phy_sgmii;
350 val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
351 hw->phy.addr, &phy_id_low);
355 hw->phy.id = (u32)phy_id_high << 16;
356 hw->phy.id |= phy_id_low & IXGBE_PHY_REVISION_MASK;
357 hw->phy.revision = (u32)phy_id_low & ~IXGBE_PHY_REVISION_MASK;
358 hw->phy.type = ixgbe_phy_m88;
364 * ixgbe_identify_phy_x550em - Get PHY type based on device id
365 * @hw: pointer to hardware structure
369 STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
371 switch (hw->device_id) {
372 case IXGBE_DEV_ID_X550EM_A_SFP:
373 hw->phy.phy_semaphore_mask = IXGBE_GSSR_TOKEN_SM;
375 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
377 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
378 return ixgbe_identify_module_generic(hw);
379 case IXGBE_DEV_ID_X550EM_X_SFP:
380 /* set up for CS4227 usage */
381 hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
382 ixgbe_setup_mux_ctl(hw);
383 ixgbe_check_cs4227(hw);
386 case IXGBE_DEV_ID_X550EM_A_SFP_N:
387 return ixgbe_identify_module_generic(hw);
389 case IXGBE_DEV_ID_X550EM_X_KX4:
390 hw->phy.type = ixgbe_phy_x550em_kx4;
392 case IXGBE_DEV_ID_X550EM_X_KR:
393 case IXGBE_DEV_ID_X550EM_A_KR:
394 case IXGBE_DEV_ID_X550EM_A_KR_L:
395 hw->phy.type = ixgbe_phy_x550em_kr;
397 case IXGBE_DEV_ID_X550EM_X_1G_T:
398 case IXGBE_DEV_ID_X550EM_X_10G_T:
399 case IXGBE_DEV_ID_X550EM_A_10G_T:
400 return ixgbe_identify_phy_generic(hw);
401 case IXGBE_DEV_ID_X550EM_A_1G_T:
402 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
403 return ixgbe_identify_phy_1g(hw);
407 return IXGBE_SUCCESS;
410 STATIC s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
411 u32 device_type, u16 *phy_data)
413 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
414 return IXGBE_NOT_IMPLEMENTED;
417 STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
418 u32 device_type, u16 phy_data)
420 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
421 return IXGBE_NOT_IMPLEMENTED;
425 * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
426 * @hw: pointer to the hardware structure
427 * @addr: I2C bus address to read from
428 * @reg: I2C device register to read from
429 * @val: pointer to location to receive read value
431 * Returns an error code on error.
433 static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
436 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
440 * ixgbe_read_i2c_combined_generic_unlocked - Do I2C read combined operation
441 * @hw: pointer to the hardware structure
442 * @addr: I2C bus address to read from
443 * @reg: I2C device register to read from
444 * @val: pointer to location to receive read value
446 * Returns an error code on error.
449 ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
452 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, false);
456 * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
457 * @hw: pointer to the hardware structure
458 * @addr: I2C bus address to write to
459 * @reg: I2C device register to write to
460 * @val: value to write
462 * Returns an error code on error.
464 static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
465 u8 addr, u16 reg, u16 val)
467 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
471 * ixgbe_write_i2c_combined_generic_unlocked - Do I2C write combined operation
472 * @hw: pointer to the hardware structure
473 * @addr: I2C bus address to write to
474 * @reg: I2C device register to write to
475 * @val: value to write
477 * Returns an error code on error.
480 ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
481 u8 addr, u16 reg, u16 val)
483 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, false);
487 * ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
488 * @hw: pointer to hardware structure
490 * Initialize the function pointers and for MAC type X550EM.
491 * Does not touch the hardware.
493 s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
495 struct ixgbe_mac_info *mac = &hw->mac;
496 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
497 struct ixgbe_phy_info *phy = &hw->phy;
498 struct ixgbe_link_info *link = &hw->link;
501 DEBUGFUNC("ixgbe_init_ops_X550EM");
503 /* Similar to X550 so start there. */
504 ret_val = ixgbe_init_ops_X550(hw);
506 /* Since this function eventually calls
507 * ixgbe_init_ops_540 by design, we are setting
508 * the pointers to NULL explicitly here to overwrite
509 * the values being set in the x540 function.
511 /* Thermal sensor not supported in x550EM */
512 mac->ops.get_thermal_sensor_data = NULL;
513 mac->ops.init_thermal_sensor_thresh = NULL;
514 mac->thermal_sensor_enabled = false;
516 /* FCOE not supported in x550EM */
517 mac->ops.get_san_mac_addr = NULL;
518 mac->ops.set_san_mac_addr = NULL;
519 mac->ops.get_wwn_prefix = NULL;
520 mac->ops.get_fcoe_boot_status = NULL;
522 /* IPsec not supported in x550EM */
523 mac->ops.disable_sec_rx_path = NULL;
524 mac->ops.enable_sec_rx_path = NULL;
526 /* AUTOC register is not present in x550EM. */
527 mac->ops.prot_autoc_read = NULL;
528 mac->ops.prot_autoc_write = NULL;
530 /* X550EM bus type is internal*/
531 hw->bus.type = ixgbe_bus_type_internal;
532 mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
534 if (hw->mac.type == ixgbe_mac_X550EM_x) {
535 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
536 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
537 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
538 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
539 link->ops.read_link = ixgbe_read_i2c_combined_generic;
540 link->ops.read_link_unlocked =
541 ixgbe_read_i2c_combined_generic_unlocked;
542 link->ops.write_link = ixgbe_write_i2c_combined_generic;
543 link->ops.write_link_unlocked =
544 ixgbe_write_i2c_combined_generic_unlocked;
545 link->addr = IXGBE_CS4227;
547 if (hw->mac.type == ixgbe_mac_X550EM_a) {
548 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
549 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
550 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
551 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
554 mac->ops.get_media_type = ixgbe_get_media_type_X550em;
555 mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
556 mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
557 mac->ops.reset_hw = ixgbe_reset_hw_X550em;
558 mac->ops.get_supported_physical_layer =
559 ixgbe_get_supported_physical_layer_X550em;
561 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
562 mac->ops.setup_fc = ixgbe_setup_fc_generic;
564 mac->ops.setup_fc = ixgbe_setup_fc_X550em;
566 switch (hw->device_id) {
567 case IXGBE_DEV_ID_X550EM_X_KR:
568 case IXGBE_DEV_ID_X550EM_A_KR:
569 case IXGBE_DEV_ID_X550EM_A_KR_L:
572 mac->ops.setup_eee = NULL;
576 phy->ops.init = ixgbe_init_phy_ops_X550em;
577 phy->ops.identify = ixgbe_identify_phy_x550em;
578 if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
579 phy->ops.set_phy_power = NULL;
583 eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
584 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
585 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
586 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
587 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
588 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
589 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
590 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
596 * ixgbe_dmac_config_X550
597 * @hw: pointer to hardware structure
599 * Configure DMA coalescing. If enabling dmac, dmac is activated.
600 * When disabling dmac, dmac enable dmac bit is cleared.
602 s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
604 u32 reg, high_pri_tc;
606 DEBUGFUNC("ixgbe_dmac_config_X550");
608 /* Disable DMA coalescing before configuring */
609 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
610 reg &= ~IXGBE_DMACR_DMAC_EN;
611 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
613 /* Disable DMA Coalescing if the watchdog timer is 0 */
614 if (!hw->mac.dmac_config.watchdog_timer)
617 ixgbe_dmac_config_tcs_X550(hw);
619 /* Configure DMA Coalescing Control Register */
620 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
622 /* Set the watchdog timer in units of 40.96 usec */
623 reg &= ~IXGBE_DMACR_DMACWT_MASK;
624 reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
626 reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
627 /* If fcoe is enabled, set high priority traffic class */
628 if (hw->mac.dmac_config.fcoe_en) {
629 high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
630 reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
631 IXGBE_DMACR_HIGH_PRI_TC_MASK);
633 reg |= IXGBE_DMACR_EN_MNG_IND;
635 /* Enable DMA coalescing after configuration */
636 reg |= IXGBE_DMACR_DMAC_EN;
637 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
640 return IXGBE_SUCCESS;
644 * ixgbe_dmac_config_tcs_X550
645 * @hw: pointer to hardware structure
647 * Configure DMA coalescing threshold per TC. The dmac enable bit must
648 * be cleared before configuring.
650 s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
652 u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
654 DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
656 /* Configure DMA coalescing enabled */
657 switch (hw->mac.dmac_config.link_speed) {
658 case IXGBE_LINK_SPEED_100_FULL:
659 pb_headroom = IXGBE_DMACRXT_100M;
661 case IXGBE_LINK_SPEED_1GB_FULL:
662 pb_headroom = IXGBE_DMACRXT_1G;
665 pb_headroom = IXGBE_DMACRXT_10G;
669 maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
670 IXGBE_MHADD_MFS_SHIFT) / 1024);
672 /* Set the per Rx packet buffer receive threshold */
673 for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
674 reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
675 reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
677 if (tc < hw->mac.dmac_config.num_tcs) {
679 rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
680 rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
681 IXGBE_RXPBSIZE_SHIFT;
683 /* Calculate receive buffer threshold in kilobytes */
684 if (rx_pb_size > pb_headroom)
685 rx_pb_size = rx_pb_size - pb_headroom;
689 /* Minimum of MFS shall be set for DMCTH */
690 reg |= (rx_pb_size > maxframe_size_kb) ?
691 rx_pb_size : maxframe_size_kb;
693 IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
695 return IXGBE_SUCCESS;
699 * ixgbe_dmac_update_tcs_X550
700 * @hw: pointer to hardware structure
702 * Disables dmac, updates per TC settings, and then enables dmac.
704 s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
708 DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
710 /* Disable DMA coalescing before configuring */
711 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
712 reg &= ~IXGBE_DMACR_DMAC_EN;
713 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
715 ixgbe_dmac_config_tcs_X550(hw);
717 /* Enable DMA coalescing after configuration */
718 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
719 reg |= IXGBE_DMACR_DMAC_EN;
720 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
722 return IXGBE_SUCCESS;
726 * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
727 * @hw: pointer to hardware structure
729 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
730 * ixgbe_hw struct in order to set up EEPROM access.
732 s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
734 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
738 DEBUGFUNC("ixgbe_init_eeprom_params_X550");
740 if (eeprom->type == ixgbe_eeprom_uninitialized) {
741 eeprom->semaphore_delay = 10;
742 eeprom->type = ixgbe_flash;
744 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
745 eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
746 IXGBE_EEC_SIZE_SHIFT);
747 eeprom->word_size = 1 << (eeprom_size +
748 IXGBE_EEPROM_WORD_SIZE_SHIFT);
750 DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
751 eeprom->type, eeprom->word_size);
754 return IXGBE_SUCCESS;
758 * ixgbe_enable_eee_x550 - Enable EEE support
759 * @hw: pointer to hardware structure
761 static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
767 if (hw->mac.type == ixgbe_mac_X550) {
768 /* Advertise EEE capability */
769 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
770 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
773 autoneg_eee_reg |= (IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
774 IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
775 IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
777 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
778 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
780 return IXGBE_SUCCESS;
783 switch (hw->device_id) {
784 case IXGBE_DEV_ID_X550EM_X_KR:
785 case IXGBE_DEV_ID_X550EM_A_KR:
786 case IXGBE_DEV_ID_X550EM_A_KR_L:
787 status = hw->mac.ops.read_iosf_sb_reg(hw,
788 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
789 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
790 if (status != IXGBE_SUCCESS)
793 link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
794 IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;
796 /* Don't advertise FEC capability when EEE enabled. */
797 link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
799 status = hw->mac.ops.write_iosf_sb_reg(hw,
800 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
801 IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
802 if (status != IXGBE_SUCCESS)
809 return IXGBE_SUCCESS;
813 * ixgbe_disable_eee_x550 - Disable EEE support
814 * @hw: pointer to hardware structure
816 static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
822 if (hw->mac.type == ixgbe_mac_X550) {
823 /* Disable advertised EEE capability */
824 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
825 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
828 autoneg_eee_reg &= ~(IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
829 IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
830 IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
832 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
833 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
835 return IXGBE_SUCCESS;
838 switch (hw->device_id) {
839 case IXGBE_DEV_ID_X550EM_X_KR:
840 case IXGBE_DEV_ID_X550EM_A_KR:
841 case IXGBE_DEV_ID_X550EM_A_KR_L:
842 status = hw->mac.ops.read_iosf_sb_reg(hw,
843 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
844 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
845 if (status != IXGBE_SUCCESS)
848 link_reg &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
849 IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX);
851 /* Advertise FEC capability when EEE is disabled. */
852 link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
854 status = hw->mac.ops.write_iosf_sb_reg(hw,
855 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
856 IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
857 if (status != IXGBE_SUCCESS)
864 return IXGBE_SUCCESS;
868 * ixgbe_setup_eee_X550 - Enable/disable EEE support
869 * @hw: pointer to the HW structure
870 * @enable_eee: boolean flag to enable EEE
872 * Enable/disable EEE based on enable_eee flag.
873 * Auto-negotiation must be started after BASE-T EEE bits in PHY register 7.3C
877 s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
882 DEBUGFUNC("ixgbe_setup_eee_X550");
884 eeer = IXGBE_READ_REG(hw, IXGBE_EEER);
885 /* Enable or disable EEE per flag */
887 eeer |= (IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
889 /* Not supported on first revision of X550EM_x. */
890 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
891 !(IXGBE_FUSES0_REV_MASK &
892 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
893 return IXGBE_SUCCESS;
894 status = ixgbe_enable_eee_x550(hw);
898 eeer &= ~(IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
900 status = ixgbe_disable_eee_x550(hw);
904 IXGBE_WRITE_REG(hw, IXGBE_EEER, eeer);
906 return IXGBE_SUCCESS;
910 * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
911 * @hw: pointer to hardware structure
912 * @enable: enable or disable source address pruning
913 * @pool: Rx pool to set source address pruning for
915 void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
920 /* max rx pool is 63 */
924 pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
925 pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
928 pfflp |= (1ULL << pool);
930 pfflp &= ~(1ULL << pool);
932 IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
933 IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
937 * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
938 * @hw: pointer to hardware structure
939 * @enable: enable or disable switch for Ethertype anti-spoofing
940 * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
943 void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
946 int vf_target_reg = vf >> 3;
947 int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
950 DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
952 pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
954 pfvfspoof |= (1 << vf_target_shift);
956 pfvfspoof &= ~(1 << vf_target_shift);
958 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
962 * ixgbe_iosf_wait - Wait for IOSF command completion
963 * @hw: pointer to hardware structure
964 * @ctrl: pointer to location to receive final IOSF control value
966 * Returns failing status on timeout
968 * Note: ctrl can be NULL if the IOSF control register value is not needed
970 STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
974 /* Check every 10 usec to see if the address cycle completed.
975 * The SB IOSF BUSY bit will clear when the operation is
978 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
979 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
980 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
986 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
987 ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
988 return IXGBE_ERR_PHY;
991 return IXGBE_SUCCESS;
995 * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
997 * @hw: pointer to hardware structure
998 * @reg_addr: 32 bit PHY register to write
999 * @device_type: 3 bit device type
1000 * @data: Data to write to the register
1002 s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
1003 u32 device_type, u32 data)
1005 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
1009 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
1010 if (ret != IXGBE_SUCCESS)
1013 ret = ixgbe_iosf_wait(hw, NULL);
1014 if (ret != IXGBE_SUCCESS)
1017 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
1018 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
1020 /* Write IOSF control register */
1021 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
1023 /* Write IOSF data register */
1024 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
1026 ret = ixgbe_iosf_wait(hw, &command);
1028 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
1029 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
1030 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
1031 ERROR_REPORT2(IXGBE_ERROR_POLLING,
1032 "Failed to write, error %x\n", error);
1033 ret = IXGBE_ERR_PHY;
1037 ixgbe_release_swfw_semaphore(hw, gssr);
1042 * ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
1044 * @hw: pointer to hardware structure
1045 * @reg_addr: 32 bit PHY register to write
1046 * @device_type: 3 bit device type
1047 * @phy_data: Pointer to read data from the register
1049 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
1050 u32 device_type, u32 *data)
1052 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
1056 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
1057 if (ret != IXGBE_SUCCESS)
1060 ret = ixgbe_iosf_wait(hw, NULL);
1061 if (ret != IXGBE_SUCCESS)
1064 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
1065 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
1067 /* Write IOSF control register */
1068 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
1070 ret = ixgbe_iosf_wait(hw, &command);
1072 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
1073 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
1074 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
1075 ERROR_REPORT2(IXGBE_ERROR_POLLING,
1076 "Failed to read, error %x\n", error);
1077 ret = IXGBE_ERR_PHY;
1080 if (ret == IXGBE_SUCCESS)
1081 *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
1084 ixgbe_release_swfw_semaphore(hw, gssr);
1089 * ixgbe_get_phy_token - Get the token for shared phy access
1090 * @hw: Pointer to hardware structure
1093 s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
1095 struct ixgbe_hic_phy_token_req token_cmd;
1098 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
1099 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
1100 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
1101 token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1102 token_cmd.port_number = hw->bus.lan_id;
1103 token_cmd.command_type = FW_PHY_TOKEN_REQ;
1105 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
1107 IXGBE_HI_COMMAND_TIMEOUT,
1111 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
1112 return IXGBE_SUCCESS;
1113 if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY)
1114 return IXGBE_ERR_FW_RESP_INVALID;
1116 return IXGBE_ERR_TOKEN_RETRY;
1120 * ixgbe_put_phy_token - Put the token for shared phy access
1121 * @hw: Pointer to hardware structure
1124 s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
1126 struct ixgbe_hic_phy_token_req token_cmd;
1129 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
1130 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
1131 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
1132 token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1133 token_cmd.port_number = hw->bus.lan_id;
1134 token_cmd.command_type = FW_PHY_TOKEN_REL;
1136 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
1138 IXGBE_HI_COMMAND_TIMEOUT,
1142 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
1143 return IXGBE_SUCCESS;
1144 return IXGBE_ERR_FW_RESP_INVALID;
1148 * ixgbe_write_iosf_sb_reg_x550a - Writes a value to specified register
1149 * of the IOSF device
1150 * @hw: pointer to hardware structure
1151 * @reg_addr: 32 bit PHY register to write
1152 * @device_type: 3 bit device type
1153 * @data: Data to write to the register
1155 s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1156 u32 device_type, u32 data)
1158 struct ixgbe_hic_internal_phy_req write_cmd;
1160 UNREFERENCED_1PARAMETER(device_type);
1162 memset(&write_cmd, 0, sizeof(write_cmd));
1163 write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1164 write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1165 write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1166 write_cmd.port_number = hw->bus.lan_id;
1167 write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
1168 write_cmd.address = (u16)reg_addr;
1169 write_cmd.write_data = data;
1171 status = ixgbe_host_interface_command(hw, (u32 *)&write_cmd,
1173 IXGBE_HI_COMMAND_TIMEOUT, false);
1179 * ixgbe_read_iosf_sb_reg_x550a - Writes a value to specified register
1180 * of the IOSF device.
1181 * @hw: pointer to hardware structure
1182 * @reg_addr: 32 bit PHY register to write
1183 * @device_type: 3 bit device type
1184 * @data: Pointer to read data from the register
1186 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1187 u32 device_type, u32 *data)
1189 struct ixgbe_hic_internal_phy_req read_cmd;
1191 UNREFERENCED_1PARAMETER(device_type);
1193 memset(&read_cmd, 0, sizeof(read_cmd));
1194 read_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1195 read_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1196 read_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1197 read_cmd.port_number = hw->bus.lan_id;
1198 read_cmd.command_type = FW_INT_PHY_REQ_READ;
1199 read_cmd.address = (u16)reg_addr;
1201 status = ixgbe_host_interface_command(hw, (u32 *)&read_cmd,
1203 IXGBE_HI_COMMAND_TIMEOUT, true);
1205 /* Extract the register value from the response. */
1206 *data = ((struct ixgbe_hic_internal_phy_resp *)&read_cmd)->read_data;
1212 * ixgbe_disable_mdd_X550
1213 * @hw: pointer to hardware structure
1215 * Disable malicious driver detection
1217 void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
1221 DEBUGFUNC("ixgbe_disable_mdd_X550");
1223 /* Disable MDD for TX DMA and interrupt */
1224 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1225 reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1226 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1228 /* Disable MDD for RX and interrupt */
1229 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1230 reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1231 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1235 * ixgbe_enable_mdd_X550
1236 * @hw: pointer to hardware structure
1238 * Enable malicious driver detection
1240 void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
1244 DEBUGFUNC("ixgbe_enable_mdd_X550");
1246 /* Enable MDD for TX DMA and interrupt */
1247 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1248 reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1249 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1251 /* Enable MDD for RX and interrupt */
1252 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1253 reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1254 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1258 * ixgbe_restore_mdd_vf_X550
1259 * @hw: pointer to hardware structure
1262 * Restore VF that was disabled during malicious driver detection event
1264 void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
1266 u32 idx, reg, num_qs, start_q, bitmask;
1268 DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
1270 /* Map VF to queues */
1271 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1272 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1273 case IXGBE_MRQC_VMDQRT8TCEN:
1274 num_qs = 8; /* 16 VFs / pools */
1275 bitmask = 0x000000FF;
1277 case IXGBE_MRQC_VMDQRSS32EN:
1278 case IXGBE_MRQC_VMDQRT4TCEN:
1279 num_qs = 4; /* 32 VFs / pools */
1280 bitmask = 0x0000000F;
1282 default: /* 64 VFs / pools */
1284 bitmask = 0x00000003;
1287 start_q = vf * num_qs;
1289 /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
1292 reg |= (bitmask << (start_q % 32));
1293 IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
1294 IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
1298 * ixgbe_mdd_event_X550
1299 * @hw: pointer to hardware structure
1300 * @vf_bitmap: vf bitmap of malicious vfs
1302 * Handle malicious driver detection event.
1304 void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
1307 u32 i, j, reg, q, shift, vf, idx;
1309 DEBUGFUNC("ixgbe_mdd_event_X550");
1311 /* figure out pool size for mapping to vf's */
1312 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1313 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1314 case IXGBE_MRQC_VMDQRT8TCEN:
1315 shift = 3; /* 16 VFs / pools */
1317 case IXGBE_MRQC_VMDQRSS32EN:
1318 case IXGBE_MRQC_VMDQRT4TCEN:
1319 shift = 2; /* 32 VFs / pools */
1322 shift = 1; /* 64 VFs / pools */
1326 /* Read WQBR_TX and WQBR_RX and check for malicious queues */
1327 for (i = 0; i < 4; i++) {
1328 wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
1329 wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
1334 /* Get malicious queue */
1335 for (j = 0; j < 32 && wqbr; j++) {
1337 if (!(wqbr & (1 << j)))
1340 /* Get queue from bitmask */
1343 /* Map queue to vf */
1346 /* Set vf bit in vf_bitmap */
1348 vf_bitmap[idx] |= (1 << (vf % 32));
1355 * ixgbe_get_media_type_X550em - Get media type
1356 * @hw: pointer to hardware structure
1358 * Returns the media type (fiber, copper, backplane)
1360 enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1362 enum ixgbe_media_type media_type;
1364 DEBUGFUNC("ixgbe_get_media_type_X550em");
1366 /* Detect if there is a copper PHY attached. */
1367 switch (hw->device_id) {
1368 case IXGBE_DEV_ID_X550EM_X_KR:
1369 case IXGBE_DEV_ID_X550EM_X_KX4:
1370 case IXGBE_DEV_ID_X550EM_A_KR:
1371 case IXGBE_DEV_ID_X550EM_A_KR_L:
1372 media_type = ixgbe_media_type_backplane;
1374 case IXGBE_DEV_ID_X550EM_X_SFP:
1375 case IXGBE_DEV_ID_X550EM_A_SFP:
1376 case IXGBE_DEV_ID_X550EM_A_SFP_N:
1377 case IXGBE_DEV_ID_X550EM_A_QSFP:
1378 case IXGBE_DEV_ID_X550EM_A_QSFP_N:
1379 media_type = ixgbe_media_type_fiber;
1381 case IXGBE_DEV_ID_X550EM_X_1G_T:
1382 case IXGBE_DEV_ID_X550EM_X_10G_T:
1383 case IXGBE_DEV_ID_X550EM_A_10G_T:
1384 media_type = ixgbe_media_type_copper;
1386 case IXGBE_DEV_ID_X550EM_A_1G_T:
1387 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
1388 media_type = ixgbe_media_type_sgmii;
1389 hw->phy.type = ixgbe_phy_sgmii;
1392 media_type = ixgbe_media_type_unknown;
1399 * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
1400 * @hw: pointer to hardware structure
1401 * @linear: true if SFP module is linear
1403 STATIC s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
1405 DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
1407 switch (hw->phy.sfp_type) {
1408 case ixgbe_sfp_type_not_present:
1409 return IXGBE_ERR_SFP_NOT_PRESENT;
1410 case ixgbe_sfp_type_da_cu_core0:
1411 case ixgbe_sfp_type_da_cu_core1:
1414 case ixgbe_sfp_type_srlr_core0:
1415 case ixgbe_sfp_type_srlr_core1:
1416 case ixgbe_sfp_type_da_act_lmt_core0:
1417 case ixgbe_sfp_type_da_act_lmt_core1:
1418 case ixgbe_sfp_type_1g_sx_core0:
1419 case ixgbe_sfp_type_1g_sx_core1:
1420 case ixgbe_sfp_type_1g_lx_core0:
1421 case ixgbe_sfp_type_1g_lx_core1:
1424 case ixgbe_sfp_type_unknown:
1425 case ixgbe_sfp_type_1g_cu_core0:
1426 case ixgbe_sfp_type_1g_cu_core1:
1428 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1431 return IXGBE_SUCCESS;
1435 * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
1436 * @hw: pointer to hardware structure
1438 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1440 s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
1445 DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
1447 status = ixgbe_identify_module_generic(hw);
1449 if (status != IXGBE_SUCCESS)
1452 /* Check if SFP module is supported */
1453 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1459 * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
1460 * @hw: pointer to hardware structure
1462 s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
1467 DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
1469 /* Check if SFP module is supported */
1470 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1472 if (status != IXGBE_SUCCESS)
1475 ixgbe_init_mac_link_ops_X550em(hw);
1476 hw->phy.ops.reset = NULL;
1478 return IXGBE_SUCCESS;
1482 * ixgbe_setup_sgmii - Set up link for sgmii
1483 * @hw: pointer to hardware structure
1485 static s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
1486 bool autoneg_wait_to_complete)
1488 struct ixgbe_mac_info *mac = &hw->mac;
1491 UNREFERENCED_2PARAMETER(speed, autoneg_wait_to_complete);
1493 rc = mac->ops.read_iosf_sb_reg(hw,
1494 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1495 IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
1499 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1500 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1501 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
1502 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
1503 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1504 rc = mac->ops.write_iosf_sb_reg(hw,
1505 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1506 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1510 rc = mac->ops.read_iosf_sb_reg(hw,
1511 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1512 IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
1516 sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
1517 sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
1518 rc = mac->ops.write_iosf_sb_reg(hw,
1519 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1520 IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
1524 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1525 rc = mac->ops.write_iosf_sb_reg(hw,
1526 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1527 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1533 * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
1534 * @hw: pointer to hardware structure
1536 void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
1538 struct ixgbe_mac_info *mac = &hw->mac;
1540 DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
1542 switch (hw->mac.ops.get_media_type(hw)) {
1543 case ixgbe_media_type_fiber:
1544 /* CS4227 does not support autoneg, so disable the laser control
1545 * functions for SFP+ fiber
1547 mac->ops.disable_tx_laser = NULL;
1548 mac->ops.enable_tx_laser = NULL;
1549 mac->ops.flap_tx_laser = NULL;
1550 mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
1551 mac->ops.set_rate_select_speed =
1552 ixgbe_set_soft_rate_select_speed;
1553 if ((hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) ||
1554 (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP))
1555 mac->ops.setup_mac_link =
1556 ixgbe_setup_mac_link_sfp_x550a;
1558 mac->ops.setup_mac_link =
1559 ixgbe_setup_mac_link_sfp_x550em;
1561 case ixgbe_media_type_copper:
1562 mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
1563 mac->ops.check_link = ixgbe_check_link_t_X550em;
1565 case ixgbe_media_type_backplane:
1567 case ixgbe_media_type_sgmii:
1568 mac->ops.setup_link = ixgbe_setup_sgmii;
1576 * ixgbe_get_link_capabilities_x550em - Determines link capabilities
1577 * @hw: pointer to hardware structure
1578 * @speed: pointer to link speed
1579 * @autoneg: true when autoneg or autotry is enabled
1581 s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
1582 ixgbe_link_speed *speed,
1585 DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
1588 if (hw->phy.media_type == ixgbe_media_type_fiber) {
1590 /* CS4227 SFP must not enable auto-negotiation */
1593 /* Check if 1G SFP module. */
1594 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1595 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
1596 || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1597 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
1598 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1599 return IXGBE_SUCCESS;
1602 /* Link capabilities are based on SFP */
1603 if (hw->phy.multispeed_fiber)
1604 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1605 IXGBE_LINK_SPEED_1GB_FULL;
1607 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1609 switch (hw->phy.type) {
1611 *speed = IXGBE_LINK_SPEED_100_FULL |
1612 IXGBE_LINK_SPEED_1GB_FULL;
1614 case ixgbe_phy_sgmii:
1615 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1618 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1619 IXGBE_LINK_SPEED_1GB_FULL;
1625 return IXGBE_SUCCESS;
1629 * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
1630 * @hw: pointer to hardware structure
1631 * @lsc: pointer to boolean flag which indicates whether external Base T
1632 * PHY interrupt is lsc
1634 * Determime if external Base T PHY interrupt cause is high temperature
1635 * failure alarm or link status change.
1637 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
1638 * failure alarm, else return PHY access status.
1640 STATIC s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
1647 /* Vendor alarm triggered */
1648 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1649 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1652 if (status != IXGBE_SUCCESS ||
1653 !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
1656 /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
1657 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
1658 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1661 if (status != IXGBE_SUCCESS ||
1662 !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1663 IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
1666 /* Global alarm triggered */
1667 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
1668 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1671 if (status != IXGBE_SUCCESS)
1674 /* If high temperature failure, then return over temp error and exit */
1675 if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
1676 /* power down the PHY in case the PHY FW didn't already */
1677 ixgbe_set_copper_phy_power(hw, false);
1678 return IXGBE_ERR_OVERTEMP;
1679 } else if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
1680 /* device fault alarm triggered */
1681 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
1682 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1685 if (status != IXGBE_SUCCESS)
1688 /* if device fault was due to high temp alarm handle and exit */
1689 if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
1690 /* power down the PHY in case the PHY FW didn't */
1691 ixgbe_set_copper_phy_power(hw, false);
1692 return IXGBE_ERR_OVERTEMP;
1696 /* Vendor alarm 2 triggered */
1697 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1698 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1700 if (status != IXGBE_SUCCESS ||
1701 !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
1704 /* link connect/disconnect event occurred */
1705 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
1706 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1708 if (status != IXGBE_SUCCESS)
1712 if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
1715 return IXGBE_SUCCESS;
1719 * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
1720 * @hw: pointer to hardware structure
1722 * Enable link status change and temperature failure alarm for the external
1725 * Returns PHY access status
1727 STATIC s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
1733 /* Clear interrupt flags */
1734 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
1736 /* Enable link status change alarm */
1737 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1738 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1740 if (status != IXGBE_SUCCESS)
1743 reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
1745 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1746 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
1748 if (status != IXGBE_SUCCESS)
1751 /* Enable high temperature failure and global fault alarms */
1752 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1753 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1756 if (status != IXGBE_SUCCESS)
1759 reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
1760 IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
1762 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1763 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1766 if (status != IXGBE_SUCCESS)
1769 /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
1770 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1771 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1774 if (status != IXGBE_SUCCESS)
1777 reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1778 IXGBE_MDIO_GLOBAL_ALARM_1_INT);
1780 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1781 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1784 if (status != IXGBE_SUCCESS)
1787 /* Enable chip-wide vendor alarm */
1788 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1789 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1792 if (status != IXGBE_SUCCESS)
1795 reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
1797 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1798 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1805 * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
1806 * @hw: pointer to hardware structure
1807 * @speed: link speed
1809 * Configures the integrated KR PHY.
1811 STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
1812 ixgbe_link_speed speed)
1817 status = hw->mac.ops.read_iosf_sb_reg(hw,
1818 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1819 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1823 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1824 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
1825 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
1827 /* Advertise 10G support. */
1828 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
1829 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
1831 /* Advertise 1G support. */
1832 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
1833 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
1835 /* Restart auto-negotiation. */
1836 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1837 status = hw->mac.ops.write_iosf_sb_reg(hw,
1838 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1839 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1845 * ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
1846 * @hw: pointer to hardware structure
1848 * Read NW_MNG_IF_SEL register and save field values, and check for valid field
1851 STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
1853 /* Save NW management interface connected on board. This is used
1854 * to determine internal PHY mode.
1856 hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
1858 /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
1859 * PHY address. This register field was has only been used for X552.
1861 if (hw->mac.type == ixgbe_mac_X550EM_a &&
1862 hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
1863 hw->phy.addr = (hw->phy.nw_mng_if_sel &
1864 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
1865 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
1868 return IXGBE_SUCCESS;
1872 * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
1873 * @hw: pointer to hardware structure
1875 * Initialize any function pointers that were not able to be
1876 * set during init_shared_code because the PHY/SFP type was
1877 * not known. Perform the SFP init if necessary.
1879 s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
1881 struct ixgbe_phy_info *phy = &hw->phy;
1884 DEBUGFUNC("ixgbe_init_phy_ops_X550em");
1886 hw->mac.ops.set_lan_id(hw);
1888 ixgbe_read_mng_if_sel_x550em(hw);
1890 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
1891 phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
1892 ixgbe_setup_mux_ctl(hw);
1893 phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
1896 /* Identify the PHY or SFP module */
1897 ret_val = phy->ops.identify(hw);
1898 if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED)
1901 /* Setup function pointers based on detected hardware */
1902 ixgbe_init_mac_link_ops_X550em(hw);
1903 if (phy->sfp_type != ixgbe_sfp_type_unknown)
1904 phy->ops.reset = NULL;
1906 /* Set functions pointers based on phy type */
1907 switch (hw->phy.type) {
1908 case ixgbe_phy_x550em_kx4:
1909 phy->ops.setup_link = NULL;
1910 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1911 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1913 case ixgbe_phy_x550em_kr:
1914 phy->ops.setup_link = ixgbe_setup_kr_x550em;
1915 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1916 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1918 case ixgbe_phy_x550em_ext_t:
1919 /* If internal link mode is XFI, then setup iXFI internal link,
1920 * else setup KR now.
1922 phy->ops.setup_internal_link =
1923 ixgbe_setup_internal_phy_t_x550em;
1925 /* setup SW LPLU only for first revision of X550EM_x */
1926 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
1927 !(IXGBE_FUSES0_REV_MASK &
1928 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
1929 phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
1931 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
1932 phy->ops.reset = ixgbe_reset_phy_t_X550em;
1934 case ixgbe_phy_sgmii:
1935 phy->ops.setup_link = NULL;
1946 * ixgbe_set_mdio_speed - Set MDIO clock speed
1947 * @hw: pointer to hardware structure
1949 static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
1953 switch (hw->device_id) {
1954 case IXGBE_DEV_ID_X550EM_X_10G_T:
1955 case IXGBE_DEV_ID_X550EM_A_1G_T:
1956 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
1957 case IXGBE_DEV_ID_X550EM_A_10G_T:
1958 case IXGBE_DEV_ID_X550EM_A_SFP:
1959 case IXGBE_DEV_ID_X550EM_A_QSFP:
1960 /* Config MDIO clock speed before the first MDIO PHY access */
1961 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
1962 hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
1963 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
1971 * ixgbe_reset_hw_X550em - Perform hardware reset
1972 * @hw: pointer to hardware structure
1974 * Resets the hardware by resetting the transmit and receive units, masks
1975 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
1978 s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
1980 ixgbe_link_speed link_speed;
1984 bool link_up = false;
1986 DEBUGFUNC("ixgbe_reset_hw_X550em");
1988 /* Call adapter stop to disable Tx/Rx and clear interrupts */
1989 status = hw->mac.ops.stop_adapter(hw);
1990 if (status != IXGBE_SUCCESS)
1993 /* flush pending Tx transactions */
1994 ixgbe_clear_tx_pending(hw);
1996 ixgbe_set_mdio_speed(hw);
1998 /* PHY ops must be identified and initialized prior to reset */
1999 status = hw->phy.ops.init(hw);
2001 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
2004 /* start the external PHY */
2005 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
2006 status = ixgbe_init_ext_t_x550em(hw);
2011 /* Setup SFP module if there is one present. */
2012 if (hw->phy.sfp_setup_needed) {
2013 status = hw->mac.ops.setup_sfp(hw);
2014 hw->phy.sfp_setup_needed = false;
2017 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
2021 if (!hw->phy.reset_disable && hw->phy.ops.reset)
2022 hw->phy.ops.reset(hw);
2025 /* Issue global reset to the MAC. Needs to be SW reset if link is up.
2026 * If link reset is used when link is up, it might reset the PHY when
2027 * mng is using it. If link is down or the flag to force full link
2028 * reset is set, then perform link reset.
2030 ctrl = IXGBE_CTRL_LNK_RST;
2031 if (!hw->force_full_reset) {
2032 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
2034 ctrl = IXGBE_CTRL_RST;
2037 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
2038 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
2039 IXGBE_WRITE_FLUSH(hw);
2041 /* Poll for reset bit to self-clear meaning reset is complete */
2042 for (i = 0; i < 10; i++) {
2044 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
2045 if (!(ctrl & IXGBE_CTRL_RST_MASK))
2049 if (ctrl & IXGBE_CTRL_RST_MASK) {
2050 status = IXGBE_ERR_RESET_FAILED;
2051 DEBUGOUT("Reset polling failed to complete.\n");
2056 /* Double resets are required for recovery from certain error
2057 * conditions. Between resets, it is necessary to stall to
2058 * allow time for any pending HW events to complete.
2060 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
2061 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
2065 /* Store the permanent mac address */
2066 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
2068 /* Store MAC address from RAR0, clear receive address registers, and
2069 * clear the multicast table. Also reset num_rar_entries to 128,
2070 * since we modify this value when programming the SAN MAC address.
2072 hw->mac.num_rar_entries = 128;
2073 hw->mac.ops.init_rx_addrs(hw);
2075 ixgbe_set_mdio_speed(hw);
2077 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
2078 ixgbe_setup_mux_ctl(hw);
2084 * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
2085 * @hw: pointer to hardware structure
2087 s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
2092 status = hw->phy.ops.read_reg(hw,
2093 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
2094 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
2097 if (status != IXGBE_SUCCESS)
2100 /* If PHY FW reset completed bit is set then this is the first
2101 * SW instance after a power on so the PHY FW must be un-stalled.
2103 if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
2104 status = hw->phy.ops.read_reg(hw,
2105 IXGBE_MDIO_GLOBAL_RES_PR_10,
2106 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2109 if (status != IXGBE_SUCCESS)
2112 reg &= ~IXGBE_MDIO_POWER_UP_STALL;
2114 status = hw->phy.ops.write_reg(hw,
2115 IXGBE_MDIO_GLOBAL_RES_PR_10,
2116 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2119 if (status != IXGBE_SUCCESS)
2127 * ixgbe_setup_kr_x550em - Configure the KR PHY.
2128 * @hw: pointer to hardware structure
2130 * Configures the integrated KR PHY for X550EM_x.
2132 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
2134 if (hw->mac.type != ixgbe_mac_X550EM_x)
2135 return IXGBE_SUCCESS;
2137 return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
2141 * ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
2142 * @hw: pointer to hardware structure
2144 * Configure the external PHY and the integrated KR PHY for SFP support.
2146 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
2147 ixgbe_link_speed speed,
2148 bool autoneg_wait_to_complete)
2151 u16 reg_slice, reg_val;
2152 bool setup_linear = false;
2153 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
2155 /* Check if SFP module is supported and linear */
2156 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
2158 /* If no SFP module present, then return success. Return success since
2159 * there is no reason to configure CS4227 and SFP not present error is
2160 * not excepted in the setup MAC link flow.
2162 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
2163 return IXGBE_SUCCESS;
2165 if (ret_val != IXGBE_SUCCESS)
2168 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
2169 /* Configure CS4227 LINE side to 10G SR. */
2170 reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB +
2171 (hw->bus.lan_id << 12);
2172 reg_val = IXGBE_CS4227_SPEED_10G;
2173 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2176 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
2177 (hw->bus.lan_id << 12);
2178 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2179 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2182 /* Configure CS4227 for HOST connection rate then type. */
2183 reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB +
2184 (hw->bus.lan_id << 12);
2185 reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ?
2186 IXGBE_CS4227_SPEED_10G : IXGBE_CS4227_SPEED_1G;
2187 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2190 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB +
2191 (hw->bus.lan_id << 12);
2193 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2195 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2196 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2199 /* Setup XFI internal link. */
2200 ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
2202 /* Configure internal PHY for KR/KX. */
2203 ixgbe_setup_kr_speed_x550em(hw, speed);
2205 /* Configure CS4227 LINE side to proper mode. */
2206 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
2207 (hw->bus.lan_id << 12);
2209 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2211 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2212 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2219 * ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
2220 * @hw: pointer to hardware structure
2222 * Configure the the integrated PHY for SFP support.
2224 s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
2225 ixgbe_link_speed speed,
2226 bool autoneg_wait_to_complete)
2230 bool setup_linear = false;
2231 u32 reg_slice, reg_phy_int, slice_offset;
2233 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
2235 /* Check if SFP module is supported and linear */
2236 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
2238 /* If no SFP module present, then return success. Return success since
2239 * SFP not present error is not excepted in the setup MAC link flow.
2241 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
2242 return IXGBE_SUCCESS;
2244 if (ret_val != IXGBE_SUCCESS)
2247 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) {
2248 /* Configure internal PHY for native SFI */
2249 ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
2250 IXGBE_KRM_AN_CNTL_8(hw->bus.lan_id),
2251 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_phy_int);
2253 if (ret_val != IXGBE_SUCCESS)
2257 reg_phy_int &= ~IXGBE_KRM_AN_CNTL_8_LIMITING;
2258 reg_phy_int |= IXGBE_KRM_AN_CNTL_8_LINEAR;
2260 reg_phy_int |= IXGBE_KRM_AN_CNTL_8_LIMITING;
2261 reg_phy_int &= ~IXGBE_KRM_AN_CNTL_8_LINEAR;
2264 ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
2265 IXGBE_KRM_AN_CNTL_8(hw->bus.lan_id),
2266 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_phy_int);
2268 if (ret_val != IXGBE_SUCCESS)
2271 /* Setup XFI/SFI internal link. */
2272 ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
2274 /* Configure internal PHY for KR/KX. */
2275 ixgbe_setup_kr_speed_x550em(hw, speed);
2277 if (hw->phy.addr == 0x0 || hw->phy.addr == 0xFFFF) {
2279 DEBUGOUT("Invalid NW_MNG_IF_SEL.MDIO_PHY_ADD value\n");
2280 return IXGBE_ERR_PHY_ADDR_INVALID;
2283 /* Get external PHY device id */
2284 ret_val = hw->phy.ops.read_reg(hw, IXGBE_CS4227_GLOBAL_ID_MSB,
2285 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2287 if (ret_val != IXGBE_SUCCESS)
2290 /* When configuring quad port CS4223, the MAC instance is part
2291 * of the slice offset.
2293 if (reg_phy_ext == IXGBE_CS4223_PHY_ID)
2294 slice_offset = (hw->bus.lan_id +
2295 (hw->bus.instance_id << 1)) << 12;
2297 slice_offset = hw->bus.lan_id << 12;
2299 /* Configure CS4227/CS4223 LINE side to proper mode. */
2300 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + slice_offset;
2302 reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2304 reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2305 ret_val = hw->phy.ops.write_reg(hw, reg_slice,
2306 IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
2312 * ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
2313 * @hw: pointer to hardware structure
2315 * iXfI configuration needed for ixgbe_mac_X550EM_x devices.
2317 STATIC s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw *hw)
2322 /* Disable training protocol FSM. */
2323 status = ixgbe_read_iosf_sb_reg_x550(hw,
2324 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2325 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2326 if (status != IXGBE_SUCCESS)
2328 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
2329 status = ixgbe_write_iosf_sb_reg_x550(hw,
2330 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2331 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2332 if (status != IXGBE_SUCCESS)
2335 /* Disable Flex from training TXFFE. */
2336 status = ixgbe_read_iosf_sb_reg_x550(hw,
2337 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
2338 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2339 if (status != IXGBE_SUCCESS)
2341 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
2342 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
2343 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
2344 status = ixgbe_write_iosf_sb_reg_x550(hw,
2345 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
2346 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2347 if (status != IXGBE_SUCCESS)
2349 status = ixgbe_read_iosf_sb_reg_x550(hw,
2350 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
2351 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2352 if (status != IXGBE_SUCCESS)
2354 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
2355 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
2356 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
2357 status = ixgbe_write_iosf_sb_reg_x550(hw,
2358 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
2359 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2360 if (status != IXGBE_SUCCESS)
2363 /* Enable override for coefficients. */
2364 status = ixgbe_read_iosf_sb_reg_x550(hw,
2365 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2366 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2367 if (status != IXGBE_SUCCESS)
2369 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
2370 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
2371 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
2372 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
2373 status = ixgbe_write_iosf_sb_reg_x550(hw,
2374 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2375 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2380 * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
2381 * @hw: pointer to hardware structure
2382 * @speed: the link speed to force
2384 * Configures the integrated KR PHY to use iXFI mode. Used to connect an
2385 * internal and external PHY at a specific speed, without autonegotiation.
2387 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
2392 /* Disable AN and force speed to 10G Serial. */
2393 status = ixgbe_read_iosf_sb_reg_x550(hw,
2394 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2395 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2396 if (status != IXGBE_SUCCESS)
2399 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2400 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2402 /* Select forced link speed for internal PHY. */
2404 case IXGBE_LINK_SPEED_10GB_FULL:
2405 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2407 case IXGBE_LINK_SPEED_1GB_FULL:
2408 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
2411 /* Other link speeds are not supported by internal KR PHY. */
2412 return IXGBE_ERR_LINK_SETUP;
2415 status = ixgbe_write_iosf_sb_reg_x550(hw,
2416 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2417 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2418 if (status != IXGBE_SUCCESS)
2421 /* Additional configuration needed for x550em_x */
2422 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2423 status = ixgbe_setup_ixfi_x550em_x(hw);
2424 if (status != IXGBE_SUCCESS)
2428 /* Toggle port SW reset by AN reset. */
2429 status = ixgbe_read_iosf_sb_reg_x550(hw,
2430 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2431 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2432 if (status != IXGBE_SUCCESS)
2434 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
2435 status = ixgbe_write_iosf_sb_reg_x550(hw,
2436 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2437 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2443 * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
2444 * @hw: address of hardware structure
2445 * @link_up: address of boolean to indicate link status
2447 * Returns error code if unable to get link status.
2449 STATIC s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
2456 /* read this twice back to back to indicate current status */
2457 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
2458 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2460 if (ret != IXGBE_SUCCESS)
2463 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
2464 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2466 if (ret != IXGBE_SUCCESS)
2469 *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
2471 return IXGBE_SUCCESS;
2475 * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
2476 * @hw: point to hardware structure
2478 * Configures the link between the integrated KR PHY and the external X557 PHY
2479 * The driver will call this function when it gets a link status change
2480 * interrupt from the X557 PHY. This function configures the link speed
2481 * between the PHYs to match the link speed of the BASE-T link.
2483 * A return of a non-zero value indicates an error, and the base driver should
2484 * not report link up.
2486 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
2488 ixgbe_link_speed force_speed;
2493 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
2494 return IXGBE_ERR_CONFIG;
2496 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
2497 /* If link is down, there is no setup necessary so return */
2498 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2499 if (status != IXGBE_SUCCESS)
2503 return IXGBE_SUCCESS;
2505 status = hw->phy.ops.read_reg(hw,
2506 IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
2507 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2509 if (status != IXGBE_SUCCESS)
2512 /* If link is still down - no setup is required so return */
2513 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2514 if (status != IXGBE_SUCCESS)
2517 return IXGBE_SUCCESS;
2519 /* clear everything but the speed and duplex bits */
2520 speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
2523 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
2524 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
2526 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
2527 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
2530 /* Internal PHY does not support anything else */
2531 return IXGBE_ERR_INVALID_LINK_SETTINGS;
2534 return ixgbe_setup_ixfi_x550em(hw, &force_speed);
2536 speed = IXGBE_LINK_SPEED_10GB_FULL |
2537 IXGBE_LINK_SPEED_1GB_FULL;
2538 return ixgbe_setup_kr_speed_x550em(hw, speed);
2543 * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
2544 * @hw: pointer to hardware structure
2546 * Configures the integrated KR PHY to use internal loopback mode.
2548 s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
2553 /* Disable AN and force speed to 10G Serial. */
2554 status = hw->mac.ops.read_iosf_sb_reg(hw,
2555 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2556 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2557 if (status != IXGBE_SUCCESS)
2559 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2560 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2561 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2562 status = hw->mac.ops.write_iosf_sb_reg(hw,
2563 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2564 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2565 if (status != IXGBE_SUCCESS)
2568 /* Set near-end loopback clocks. */
2569 status = hw->mac.ops.read_iosf_sb_reg(hw,
2570 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
2571 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2572 if (status != IXGBE_SUCCESS)
2574 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
2575 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
2576 status = hw->mac.ops.write_iosf_sb_reg(hw,
2577 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
2578 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2579 if (status != IXGBE_SUCCESS)
2582 /* Set loopback enable. */
2583 status = hw->mac.ops.read_iosf_sb_reg(hw,
2584 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
2585 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2586 if (status != IXGBE_SUCCESS)
2588 reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
2589 status = hw->mac.ops.write_iosf_sb_reg(hw,
2590 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
2591 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2592 if (status != IXGBE_SUCCESS)
2595 /* Training bypass. */
2596 status = hw->mac.ops.read_iosf_sb_reg(hw,
2597 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2598 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2599 if (status != IXGBE_SUCCESS)
2601 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
2602 status = hw->mac.ops.write_iosf_sb_reg(hw,
2603 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2604 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2610 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2611 * assuming that the semaphore is already obtained.
2612 * @hw: pointer to hardware structure
2613 * @offset: offset of word in the EEPROM to read
2614 * @data: word read from the EEPROM
2616 * Reads a 16 bit word from the EEPROM using the hostif.
2618 s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2622 struct ixgbe_hic_read_shadow_ram buffer;
2624 DEBUGFUNC("ixgbe_read_ee_hostif_data_X550");
2625 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2626 buffer.hdr.req.buf_lenh = 0;
2627 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2628 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2630 /* convert offset from words to bytes */
2631 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2633 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2635 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2637 IXGBE_HI_COMMAND_TIMEOUT, false);
2642 *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
2643 FW_NVM_DATA_OFFSET);
2649 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2650 * @hw: pointer to hardware structure
2651 * @offset: offset of word in the EEPROM to read
2652 * @data: word read from the EEPROM
2654 * Reads a 16 bit word from the EEPROM using the hostif.
2656 s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2659 s32 status = IXGBE_SUCCESS;
2661 DEBUGFUNC("ixgbe_read_ee_hostif_X550");
2663 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2665 status = ixgbe_read_ee_hostif_data_X550(hw, offset, data);
2666 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2668 status = IXGBE_ERR_SWFW_SYNC;
2675 * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
2676 * @hw: pointer to hardware structure
2677 * @offset: offset of word in the EEPROM to read
2678 * @words: number of words
2679 * @data: word(s) read from the EEPROM
2681 * Reads a 16 bit word(s) from the EEPROM using the hostif.
2683 s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2684 u16 offset, u16 words, u16 *data)
2686 struct ixgbe_hic_read_shadow_ram buffer;
2687 u32 current_word = 0;
2692 DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
2694 /* Take semaphore for the entire operation. */
2695 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2697 DEBUGOUT("EEPROM read buffer - semaphore failed\n");
2701 if (words > FW_MAX_READ_BUFFER_SIZE / 2)
2702 words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
2704 words_to_read = words;
2706 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2707 buffer.hdr.req.buf_lenh = 0;
2708 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2709 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2711 /* convert offset from words to bytes */
2712 buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
2713 buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
2715 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2717 IXGBE_HI_COMMAND_TIMEOUT,
2721 DEBUGOUT("Host interface command failed\n");
2725 for (i = 0; i < words_to_read; i++) {
2726 u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
2728 u32 value = IXGBE_READ_REG(hw, reg);
2730 data[current_word] = (u16)(value & 0xffff);
2733 if (i < words_to_read) {
2735 data[current_word] = (u16)(value & 0xffff);
2739 words -= words_to_read;
2743 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2748 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2749 * @hw: pointer to hardware structure
2750 * @offset: offset of word in the EEPROM to write
2751 * @data: word write to the EEPROM
2753 * Write a 16 bit word to the EEPROM using the hostif.
2755 s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2759 struct ixgbe_hic_write_shadow_ram buffer;
2761 DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
2763 buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
2764 buffer.hdr.req.buf_lenh = 0;
2765 buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
2766 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2769 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2771 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2773 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2775 IXGBE_HI_COMMAND_TIMEOUT, false);
2781 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2782 * @hw: pointer to hardware structure
2783 * @offset: offset of word in the EEPROM to write
2784 * @data: word write to the EEPROM
2786 * Write a 16 bit word to the EEPROM using the hostif.
2788 s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2791 s32 status = IXGBE_SUCCESS;
2793 DEBUGFUNC("ixgbe_write_ee_hostif_X550");
2795 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2797 status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
2798 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2800 DEBUGOUT("write ee hostif failed to get semaphore");
2801 status = IXGBE_ERR_SWFW_SYNC;
2808 * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
2809 * @hw: pointer to hardware structure
2810 * @offset: offset of word in the EEPROM to write
2811 * @words: number of words
2812 * @data: word(s) write to the EEPROM
2814 * Write a 16 bit word(s) to the EEPROM using the hostif.
2816 s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2817 u16 offset, u16 words, u16 *data)
2819 s32 status = IXGBE_SUCCESS;
2822 DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
2824 /* Take semaphore for the entire operation. */
2825 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2826 if (status != IXGBE_SUCCESS) {
2827 DEBUGOUT("EEPROM write buffer - semaphore failed\n");
2831 for (i = 0; i < words; i++) {
2832 status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
2835 if (status != IXGBE_SUCCESS) {
2836 DEBUGOUT("Eeprom buffered write failed\n");
2841 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2848 * ixgbe_checksum_ptr_x550 - Checksum one pointer region
2849 * @hw: pointer to hardware structure
2850 * @ptr: pointer offset in eeprom
2851 * @size: size of section pointed by ptr, if 0 first word will be used as size
2852 * @csum: address of checksum to update
2854 * Returns error status for any failure
2856 STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
2857 u16 size, u16 *csum, u16 *buffer,
2862 u16 length, bufsz, i, start;
2865 bufsz = sizeof(buf) / sizeof(buf[0]);
2867 /* Read a chunk at the pointer location */
2869 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
2871 DEBUGOUT("Failed to read EEPROM image\n");
2876 if (buffer_size < ptr)
2877 return IXGBE_ERR_PARAM;
2878 local_buffer = &buffer[ptr];
2886 length = local_buffer[0];
2888 /* Skip pointer section if length is invalid. */
2889 if (length == 0xFFFF || length == 0 ||
2890 (ptr + length) >= hw->eeprom.word_size)
2891 return IXGBE_SUCCESS;
2894 if (buffer && ((u32)start + (u32)length > buffer_size))
2895 return IXGBE_ERR_PARAM;
2897 for (i = start; length; i++, length--) {
2898 if (i == bufsz && !buffer) {
2904 /* Read a chunk at the pointer location */
2905 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
2908 DEBUGOUT("Failed to read EEPROM image\n");
2912 *csum += local_buffer[i];
2914 return IXGBE_SUCCESS;
2918 * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
2919 * @hw: pointer to hardware structure
2920 * @buffer: pointer to buffer containing calculated checksum
2921 * @buffer_size: size of buffer
2923 * Returns a negative error code on error, or the 16-bit checksum
2925 s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
2927 u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
2931 u16 pointer, i, size;
2933 DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
2935 hw->eeprom.ops.init_params(hw);
2938 /* Read pointer area */
2939 status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
2940 IXGBE_EEPROM_LAST_WORD + 1,
2943 DEBUGOUT("Failed to read EEPROM image\n");
2946 local_buffer = eeprom_ptrs;
2948 if (buffer_size < IXGBE_EEPROM_LAST_WORD)
2949 return IXGBE_ERR_PARAM;
2950 local_buffer = buffer;
2954 * For X550 hardware include 0x0-0x41 in the checksum, skip the
2955 * checksum word itself
2957 for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
2958 if (i != IXGBE_EEPROM_CHECKSUM)
2959 checksum += local_buffer[i];
2962 * Include all data from pointers 0x3, 0x6-0xE. This excludes the
2963 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
2965 for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
2966 if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
2969 pointer = local_buffer[i];
2971 /* Skip pointer section if the pointer is invalid. */
2972 if (pointer == 0xFFFF || pointer == 0 ||
2973 pointer >= hw->eeprom.word_size)
2977 case IXGBE_PCIE_GENERAL_PTR:
2978 size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
2980 case IXGBE_PCIE_CONFIG0_PTR:
2981 case IXGBE_PCIE_CONFIG1_PTR:
2982 size = IXGBE_PCIE_CONFIG_SIZE;
2989 status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
2990 buffer, buffer_size);
2995 checksum = (u16)IXGBE_EEPROM_SUM - checksum;
2997 return (s32)checksum;
3001 * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
3002 * @hw: pointer to hardware structure
3004 * Returns a negative error code on error, or the 16-bit checksum
3006 s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
3008 return ixgbe_calc_checksum_X550(hw, NULL, 0);
3012 * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
3013 * @hw: pointer to hardware structure
3014 * @checksum_val: calculated checksum
3016 * Performs checksum calculation and validates the EEPROM checksum. If the
3017 * caller does not need checksum_val, the value can be NULL.
3019 s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
3023 u16 read_checksum = 0;
3025 DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
3027 /* Read the first word from the EEPROM. If this times out or fails, do
3028 * not continue or we could be in for a very long wait while every
3031 status = hw->eeprom.ops.read(hw, 0, &checksum);
3033 DEBUGOUT("EEPROM read failed\n");
3037 status = hw->eeprom.ops.calc_checksum(hw);
3041 checksum = (u16)(status & 0xffff);
3043 status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
3048 /* Verify read checksum from EEPROM is the same as
3049 * calculated checksum
3051 if (read_checksum != checksum) {
3052 status = IXGBE_ERR_EEPROM_CHECKSUM;
3053 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
3054 "Invalid EEPROM checksum");
3057 /* If the user cares, return the calculated checksum */
3059 *checksum_val = checksum;
3065 * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
3066 * @hw: pointer to hardware structure
3068 * After writing EEPROM to shadow RAM using EEWR register, software calculates
3069 * checksum and updates the EEPROM and instructs the hardware to update
3072 s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
3077 DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
3079 /* Read the first word from the EEPROM. If this times out or fails, do
3080 * not continue or we could be in for a very long wait while every
3083 status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
3085 DEBUGOUT("EEPROM read failed\n");
3089 status = ixgbe_calc_eeprom_checksum_X550(hw);
3093 checksum = (u16)(status & 0xffff);
3095 status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
3100 status = ixgbe_update_flash_X550(hw);
3106 * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
3107 * @hw: pointer to hardware structure
3109 * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
3111 s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
3113 s32 status = IXGBE_SUCCESS;
3114 union ixgbe_hic_hdr2 buffer;
3116 DEBUGFUNC("ixgbe_update_flash_X550");
3118 buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
3119 buffer.req.buf_lenh = 0;
3120 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
3121 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
3123 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
3125 IXGBE_HI_COMMAND_TIMEOUT, false);
3131 * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
3132 * @hw: pointer to hardware structure
3134 * Determines physical layer capabilities of the current configuration.
3136 u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
3138 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
3139 u16 ext_ability = 0;
3141 DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
3143 hw->phy.ops.identify(hw);
3145 switch (hw->phy.type) {
3146 case ixgbe_phy_x550em_kr:
3147 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
3148 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3150 case ixgbe_phy_x550em_kx4:
3151 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
3152 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3154 case ixgbe_phy_x550em_ext_t:
3155 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
3156 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
3158 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
3159 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
3160 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
3161 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3167 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
3168 physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
3170 return physical_layer;
3174 * ixgbe_get_bus_info_x550em - Set PCI bus info
3175 * @hw: pointer to hardware structure
3177 * Sets bus link width and speed to unknown because X550em is
3180 s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
3183 DEBUGFUNC("ixgbe_get_bus_info_x550em");
3185 hw->bus.width = ixgbe_bus_width_unknown;
3186 hw->bus.speed = ixgbe_bus_speed_unknown;
3188 hw->mac.ops.set_lan_id(hw);
3190 return IXGBE_SUCCESS;
3194 * ixgbe_disable_rx_x550 - Disable RX unit
3196 * Enables the Rx DMA unit for x550
3198 void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
3200 u32 rxctrl, pfdtxgswc;
3202 struct ixgbe_hic_disable_rxen fw_cmd;
3204 DEBUGFUNC("ixgbe_enable_rx_dma_x550");
3206 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
3207 if (rxctrl & IXGBE_RXCTRL_RXEN) {
3208 pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
3209 if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
3210 pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
3211 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
3212 hw->mac.set_lben = true;
3214 hw->mac.set_lben = false;
3217 fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
3218 fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
3219 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
3220 fw_cmd.port_number = (u8)hw->bus.lan_id;
3222 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
3223 sizeof(struct ixgbe_hic_disable_rxen),
3224 IXGBE_HI_COMMAND_TIMEOUT, true);
3226 /* If we fail - disable RX using register write */
3228 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
3229 if (rxctrl & IXGBE_RXCTRL_RXEN) {
3230 rxctrl &= ~IXGBE_RXCTRL_RXEN;
3231 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
3238 * ixgbe_enter_lplu_x550em - Transition to low power states
3239 * @hw: pointer to hardware structure
3241 * Configures Low Power Link Up on transition to low power states
3242 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
3243 * X557 PHY immediately prior to entering LPLU.
3245 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
3247 u16 an_10g_cntl_reg, autoneg_reg, speed;
3249 ixgbe_link_speed lcd_speed;
3253 /* SW LPLU not required on later HW revisions. */
3254 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
3255 (IXGBE_FUSES0_REV_MASK &
3256 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
3257 return IXGBE_SUCCESS;
3259 /* If blocked by MNG FW, then don't restart AN */
3260 if (ixgbe_check_reset_blocked(hw))
3261 return IXGBE_SUCCESS;
3263 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3264 if (status != IXGBE_SUCCESS)
3267 status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
3269 if (status != IXGBE_SUCCESS)
3272 /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
3273 * disabled, then force link down by entering low power mode.
3275 if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
3276 !(hw->wol_enabled || ixgbe_mng_present(hw)))
3277 return ixgbe_set_copper_phy_power(hw, FALSE);
3280 status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
3282 if (status != IXGBE_SUCCESS)
3285 /* If no valid LCD link speed, then force link down and exit. */
3286 if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
3287 return ixgbe_set_copper_phy_power(hw, FALSE);
3289 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
3290 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3293 if (status != IXGBE_SUCCESS)
3296 /* If no link now, speed is invalid so take link down */
3297 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3298 if (status != IXGBE_SUCCESS)
3299 return ixgbe_set_copper_phy_power(hw, false);
3301 /* clear everything but the speed bits */
3302 speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
3304 /* If current speed is already LCD, then exit. */
3305 if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
3306 (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
3307 ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
3308 (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
3311 /* Clear AN completed indication */
3312 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
3313 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3316 if (status != IXGBE_SUCCESS)
3319 status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
3320 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3323 if (status != IXGBE_SUCCESS)
3326 status = hw->phy.ops.read_reg(hw,
3327 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
3328 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3331 if (status != IXGBE_SUCCESS)
3334 save_autoneg = hw->phy.autoneg_advertised;
3336 /* Setup link at least common link speed */
3337 status = hw->mac.ops.setup_link(hw, lcd_speed, false);
3339 /* restore autoneg from before setting lplu speed */
3340 hw->phy.autoneg_advertised = save_autoneg;
3346 * ixgbe_get_lcd_x550em - Determine lowest common denominator
3347 * @hw: pointer to hardware structure
3348 * @lcd_speed: pointer to lowest common link speed
3350 * Determine lowest common link speed with link partner.
3352 s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
3356 u16 word = hw->eeprom.ctrl_word_3;
3358 *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
3360 status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
3361 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3364 if (status != IXGBE_SUCCESS)
3367 /* If link partner advertised 1G, return 1G */
3368 if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
3369 *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
3373 /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
3374 if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
3375 (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
3378 /* Link partner not capable of lower speeds, return 10G */
3379 *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
3384 * ixgbe_setup_fc_X550em - Set up flow control
3385 * @hw: pointer to hardware structure
3387 * Called at init time to set up flow control.
3389 s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
3391 s32 ret_val = IXGBE_SUCCESS;
3392 u32 pause, asm_dir, reg_val;
3394 DEBUGFUNC("ixgbe_setup_fc_X550em");
3396 /* Validate the requested mode */
3397 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
3398 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
3399 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
3400 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3404 /* 10gig parts do not have a word in the EEPROM to determine the
3405 * default flow control setting, so we explicitly set it to full.
3407 if (hw->fc.requested_mode == ixgbe_fc_default)
3408 hw->fc.requested_mode = ixgbe_fc_full;
3410 /* Determine PAUSE and ASM_DIR bits. */
3411 switch (hw->fc.requested_mode) {
3416 case ixgbe_fc_tx_pause:
3420 case ixgbe_fc_rx_pause:
3421 /* Rx Flow control is enabled and Tx Flow control is
3422 * disabled by software override. Since there really
3423 * isn't a way to advertise that we are capable of RX
3424 * Pause ONLY, we will advertise that we support both
3425 * symmetric and asymmetric Rx PAUSE, as such we fall
3426 * through to the fc_full statement. Later, we will
3427 * disable the adapter's ability to send PAUSE frames.
3434 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
3435 "Flow control param set incorrectly\n");
3436 ret_val = IXGBE_ERR_CONFIG;
3440 switch (hw->device_id) {
3441 case IXGBE_DEV_ID_X550EM_X_KR:
3442 case IXGBE_DEV_ID_X550EM_A_KR:
3443 case IXGBE_DEV_ID_X550EM_A_KR_L:
3444 ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
3445 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
3446 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3447 if (ret_val != IXGBE_SUCCESS)
3449 reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
3450 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
3452 reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
3454 reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
3455 ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
3456 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
3457 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3459 /* This device does not fully support AN. */
3460 hw->fc.disable_fc_autoneg = true;
3471 * ixgbe_set_mux - Set mux for port 1 access with CS4227
3472 * @hw: pointer to hardware structure
3473 * @state: set mux if 1, clear if 0
3475 STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
3479 if (!hw->bus.lan_id)
3481 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
3483 esdp |= IXGBE_ESDP_SDP1;
3485 esdp &= ~IXGBE_ESDP_SDP1;
3486 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
3487 IXGBE_WRITE_FLUSH(hw);
3491 * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
3492 * @hw: pointer to hardware structure
3493 * @mask: Mask to specify which semaphore to acquire
3495 * Acquires the SWFW semaphore and sets the I2C MUX
3497 s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
3501 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
3503 status = ixgbe_acquire_swfw_sync_X540(hw, mask);
3507 if (mask & IXGBE_GSSR_I2C_MASK)
3508 ixgbe_set_mux(hw, 1);
3510 return IXGBE_SUCCESS;
3514 * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
3515 * @hw: pointer to hardware structure
3516 * @mask: Mask to specify which semaphore to release
3518 * Releases the SWFW semaphore and sets the I2C MUX
3520 void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
3522 DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
3524 if (mask & IXGBE_GSSR_I2C_MASK)
3525 ixgbe_set_mux(hw, 0);
3527 ixgbe_release_swfw_sync_X540(hw, mask);
3531 * ixgbe_acquire_swfw_sync_X550a - Acquire SWFW semaphore
3532 * @hw: pointer to hardware structure
3533 * @mask: Mask to specify which semaphore to acquire
3535 * Acquires the SWFW semaphore and get the shared phy token as needed
3537 static s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
3539 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
3540 int retries = FW_PHY_TOKEN_RETRIES;
3541 s32 status = IXGBE_SUCCESS;
3543 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550a");
3546 status = IXGBE_SUCCESS;
3548 status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
3551 if (!(mask & IXGBE_GSSR_TOKEN_SM))
3552 return IXGBE_SUCCESS;
3554 status = ixgbe_get_phy_token(hw);
3555 if (status == IXGBE_SUCCESS)
3556 return IXGBE_SUCCESS;
3559 ixgbe_release_swfw_sync_X540(hw, hmask);
3560 if (status != IXGBE_ERR_TOKEN_RETRY)
3562 msec_delay(FW_PHY_TOKEN_DELAY);
3569 * ixgbe_release_swfw_sync_X550a - Release SWFW semaphore
3570 * @hw: pointer to hardware structure
3571 * @mask: Mask to specify which semaphore to release
3573 * Releases the SWFW semaphore and puts the shared phy token as needed
3575 static void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
3577 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
3579 DEBUGFUNC("ixgbe_release_swfw_sync_X550a");
3581 if (mask & IXGBE_GSSR_TOKEN_SM)
3582 ixgbe_put_phy_token(hw);
3585 ixgbe_release_swfw_sync_X540(hw, hmask);
3589 * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
3590 * @hw: pointer to hardware structure
3592 * Handle external Base T PHY interrupt. If high temperature
3593 * failure alarm then return error, else if link status change
3594 * then setup internal/external PHY link
3596 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
3597 * failure alarm, else return PHY access status.
3599 s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
3604 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
3606 if (status != IXGBE_SUCCESS)
3610 return ixgbe_setup_internal_phy(hw);
3612 return IXGBE_SUCCESS;
3616 * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
3617 * @hw: pointer to hardware structure
3618 * @speed: new link speed
3619 * @autoneg_wait_to_complete: true when waiting for completion is needed
3621 * Setup internal/external PHY link speed based on link speed, then set
3622 * external PHY auto advertised link speed.
3624 * Returns error status for any failure
3626 s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
3627 ixgbe_link_speed speed,
3628 bool autoneg_wait_to_complete)
3631 ixgbe_link_speed force_speed;
3633 DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
3635 /* Setup internal/external PHY link speed to iXFI (10G), unless
3636 * only 1G is auto advertised then setup KX link.
3638 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
3639 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
3641 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
3643 /* If internal link mode is XFI, then setup XFI internal link. */
3644 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
3645 status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
3647 if (status != IXGBE_SUCCESS)
3651 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
3655 * ixgbe_check_link_t_X550em - Determine link and speed status
3656 * @hw: pointer to hardware structure
3657 * @speed: pointer to link speed
3658 * @link_up: true when link is up
3659 * @link_up_wait_to_complete: bool used to wait for link up or not
3661 * Check that both the MAC and X557 external PHY have link.
3663 s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
3664 bool *link_up, bool link_up_wait_to_complete)
3669 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
3670 return IXGBE_ERR_CONFIG;
3672 status = ixgbe_check_mac_link_generic(hw, speed, link_up,
3673 link_up_wait_to_complete);
3675 /* If check link fails or MAC link is not up, then return */
3676 if (status != IXGBE_SUCCESS || !(*link_up))
3679 /* MAC link is up, so check external PHY link.
3680 * Read this twice back to back to indicate current status.
3682 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3683 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3686 if (status != IXGBE_SUCCESS)
3689 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3690 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3693 if (status != IXGBE_SUCCESS)
3696 /* If external PHY link is not up, then indicate link not up */
3697 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
3700 return IXGBE_SUCCESS;
3704 * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
3705 * @hw: pointer to hardware structure
3707 s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
3711 status = ixgbe_reset_phy_generic(hw);
3713 if (status != IXGBE_SUCCESS)
3716 /* Configure Link Status Alarm and Temperature Threshold interrupts */
3717 return ixgbe_enable_lasi_ext_t_x550em(hw);
3721 * ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
3722 * @hw: pointer to hardware structure
3723 * @led_idx: led number to turn on
3725 s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
3729 DEBUGFUNC("ixgbe_led_on_t_X550em");
3731 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
3732 return IXGBE_ERR_PARAM;
3734 /* To turn on the LED, set mode to ON. */
3735 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3736 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
3737 phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
3738 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3739 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
3741 return IXGBE_SUCCESS;
3745 * ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
3746 * @hw: pointer to hardware structure
3747 * @led_idx: led number to turn off
3749 s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
3753 DEBUGFUNC("ixgbe_led_off_t_X550em");
3755 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
3756 return IXGBE_ERR_PARAM;
3758 /* To turn on the LED, set mode to ON. */
3759 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3760 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
3761 phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
3762 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3763 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
3765 return IXGBE_SUCCESS;