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);
44 STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw);
47 * ixgbe_init_ops_X550 - Inits func ptrs and MAC type
48 * @hw: pointer to hardware structure
50 * Initialize the function pointers and assign the MAC type for X550.
51 * Does not touch the hardware.
53 s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
55 struct ixgbe_mac_info *mac = &hw->mac;
56 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
59 DEBUGFUNC("ixgbe_init_ops_X550");
61 ret_val = ixgbe_init_ops_X540(hw);
62 mac->ops.dmac_config = ixgbe_dmac_config_X550;
63 mac->ops.dmac_config_tcs = ixgbe_dmac_config_tcs_X550;
64 mac->ops.dmac_update_tcs = ixgbe_dmac_update_tcs_X550;
65 mac->ops.setup_eee = NULL;
66 mac->ops.set_source_address_pruning =
67 ixgbe_set_source_address_pruning_X550;
68 mac->ops.set_ethertype_anti_spoofing =
69 ixgbe_set_ethertype_anti_spoofing_X550;
71 mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
72 eeprom->ops.init_params = ixgbe_init_eeprom_params_X550;
73 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
74 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
75 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
76 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
77 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
78 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
79 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
81 mac->ops.disable_mdd = ixgbe_disable_mdd_X550;
82 mac->ops.enable_mdd = ixgbe_enable_mdd_X550;
83 mac->ops.mdd_event = ixgbe_mdd_event_X550;
84 mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
85 mac->ops.disable_rx = ixgbe_disable_rx_x550;
86 /* Manageability interface */
87 mac->ops.set_fw_drv_ver = ixgbe_set_fw_drv_ver_x550;
88 switch (hw->device_id) {
89 case IXGBE_DEV_ID_X550EM_X_1G_T:
90 hw->mac.ops.led_on = NULL;
91 hw->mac.ops.led_off = NULL;
93 case IXGBE_DEV_ID_X550EM_X_10G_T:
94 case IXGBE_DEV_ID_X550EM_A_10G_T:
95 hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
96 hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
105 * ixgbe_read_cs4227 - Read CS4227 register
106 * @hw: pointer to hardware structure
107 * @reg: register number to write
108 * @value: pointer to receive value read
110 * Returns status code
112 STATIC s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
114 return hw->link.ops.read_link_unlocked(hw, hw->link.addr, reg, value);
118 * ixgbe_write_cs4227 - Write CS4227 register
119 * @hw: pointer to hardware structure
120 * @reg: register number to write
121 * @value: value to write to register
123 * Returns status code
125 STATIC s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
127 return hw->link.ops.write_link_unlocked(hw, hw->link.addr, reg, value);
131 * ixgbe_read_pe - Read register from port expander
132 * @hw: pointer to hardware structure
133 * @reg: register number to read
134 * @value: pointer to receive read value
136 * Returns status code
138 STATIC s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
142 status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
143 if (status != IXGBE_SUCCESS)
144 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
145 "port expander access failed with %d\n", status);
150 * ixgbe_write_pe - Write register to port expander
151 * @hw: pointer to hardware structure
152 * @reg: register number to write
153 * @value: value to write
155 * Returns status code
157 STATIC s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
161 status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
162 if (status != IXGBE_SUCCESS)
163 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
164 "port expander access failed with %d\n", status);
169 * ixgbe_reset_cs4227 - Reset CS4227 using port expander
170 * @hw: pointer to hardware structure
172 * This function assumes that the caller has acquired the proper semaphore.
175 STATIC s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
182 /* Trigger hard reset. */
183 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
184 if (status != IXGBE_SUCCESS)
186 reg |= IXGBE_PE_BIT1;
187 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
188 if (status != IXGBE_SUCCESS)
191 status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, ®);
192 if (status != IXGBE_SUCCESS)
194 reg &= ~IXGBE_PE_BIT1;
195 status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
196 if (status != IXGBE_SUCCESS)
199 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
200 if (status != IXGBE_SUCCESS)
202 reg &= ~IXGBE_PE_BIT1;
203 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
204 if (status != IXGBE_SUCCESS)
207 usec_delay(IXGBE_CS4227_RESET_HOLD);
209 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
210 if (status != IXGBE_SUCCESS)
212 reg |= IXGBE_PE_BIT1;
213 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
214 if (status != IXGBE_SUCCESS)
217 /* Wait for the reset to complete. */
218 msec_delay(IXGBE_CS4227_RESET_DELAY);
219 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
220 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EFUSE_STATUS,
222 if (status == IXGBE_SUCCESS &&
223 value == IXGBE_CS4227_EEPROM_LOAD_OK)
225 msec_delay(IXGBE_CS4227_CHECK_DELAY);
227 if (retry == IXGBE_CS4227_RETRIES) {
228 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
229 "CS4227 reset did not complete.");
230 return IXGBE_ERR_PHY;
233 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_EEPROM_STATUS, &value);
234 if (status != IXGBE_SUCCESS ||
235 !(value & IXGBE_CS4227_EEPROM_LOAD_OK)) {
236 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
237 "CS4227 EEPROM did not load successfully.");
238 return IXGBE_ERR_PHY;
241 return IXGBE_SUCCESS;
245 * ixgbe_check_cs4227 - Check CS4227 and reset as needed
246 * @hw: pointer to hardware structure
248 STATIC void ixgbe_check_cs4227(struct ixgbe_hw *hw)
250 s32 status = IXGBE_SUCCESS;
251 u32 swfw_mask = hw->phy.phy_semaphore_mask;
255 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
256 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
257 if (status != IXGBE_SUCCESS) {
258 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
259 "semaphore failed with %d", status);
260 msec_delay(IXGBE_CS4227_CHECK_DELAY);
264 /* Get status of reset flow. */
265 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
267 if (status == IXGBE_SUCCESS &&
268 value == IXGBE_CS4227_RESET_COMPLETE)
271 if (status != IXGBE_SUCCESS ||
272 value != IXGBE_CS4227_RESET_PENDING)
275 /* Reset is pending. Wait and check again. */
276 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
277 msec_delay(IXGBE_CS4227_CHECK_DELAY);
280 /* If still pending, assume other instance failed. */
281 if (retry == IXGBE_CS4227_RETRIES) {
282 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
283 if (status != IXGBE_SUCCESS) {
284 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
285 "semaphore failed with %d", status);
290 /* Reset the CS4227. */
291 status = ixgbe_reset_cs4227(hw);
292 if (status != IXGBE_SUCCESS) {
293 ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE,
294 "CS4227 reset failed: %d", status);
298 /* Reset takes so long, temporarily release semaphore in case the
299 * other driver instance is waiting for the reset indication.
301 ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
302 IXGBE_CS4227_RESET_PENDING);
303 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
305 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
306 if (status != IXGBE_SUCCESS) {
307 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
308 "semaphore failed with %d", status);
312 /* Record completion for next time. */
313 status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
314 IXGBE_CS4227_RESET_COMPLETE);
317 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
318 msec_delay(hw->eeprom.semaphore_delay);
322 * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
323 * @hw: pointer to hardware structure
325 STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
327 u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
329 if (hw->bus.lan_id) {
330 esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
331 esdp |= IXGBE_ESDP_SDP1_DIR;
333 esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
334 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
335 IXGBE_WRITE_FLUSH(hw);
339 * ixgbe_identify_phy_x550em - Get PHY type based on device id
340 * @hw: pointer to hardware structure
344 STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
346 hw->mac.ops.set_lan_id(hw);
348 ixgbe_read_mng_if_sel_x550em(hw);
350 switch (hw->device_id) {
351 case IXGBE_DEV_ID_X550EM_A_SFP:
352 return ixgbe_identify_module_generic(hw);
353 case IXGBE_DEV_ID_X550EM_X_SFP:
354 /* set up for CS4227 usage */
355 ixgbe_setup_mux_ctl(hw);
356 ixgbe_check_cs4227(hw);
359 case IXGBE_DEV_ID_X550EM_A_SFP_N:
360 return ixgbe_identify_module_generic(hw);
362 case IXGBE_DEV_ID_X550EM_X_KX4:
363 hw->phy.type = ixgbe_phy_x550em_kx4;
365 case IXGBE_DEV_ID_X550EM_X_XFI:
366 hw->phy.type = ixgbe_phy_x550em_xfi;
368 case IXGBE_DEV_ID_X550EM_X_KR:
369 case IXGBE_DEV_ID_X550EM_A_KR:
370 case IXGBE_DEV_ID_X550EM_A_KR_L:
371 hw->phy.type = ixgbe_phy_x550em_kr;
373 case IXGBE_DEV_ID_X550EM_A_10G_T:
374 case IXGBE_DEV_ID_X550EM_X_10G_T:
375 return ixgbe_identify_phy_generic(hw);
376 case IXGBE_DEV_ID_X550EM_X_1G_T:
377 hw->phy.type = ixgbe_phy_ext_1g_t;
379 case IXGBE_DEV_ID_X550EM_A_1G_T:
380 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
381 hw->phy.type = ixgbe_phy_fw;
383 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
385 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
390 return IXGBE_SUCCESS;
394 * ixgbe_fw_phy_activity - Perform an activity on a PHY
395 * @hw: pointer to hardware structure
396 * @activity: activity to perform
397 * @data: Pointer to 4 32-bit words of data
399 s32 ixgbe_fw_phy_activity(struct ixgbe_hw *hw, u16 activity,
400 u32 (*data)[FW_PHY_ACT_DATA_COUNT])
403 struct ixgbe_hic_phy_activity_req cmd;
404 struct ixgbe_hic_phy_activity_resp rsp;
406 u16 retries = FW_PHY_ACT_RETRIES;
411 memset(&hic, 0, sizeof(hic));
412 hic.cmd.hdr.cmd = FW_PHY_ACT_REQ_CMD;
413 hic.cmd.hdr.buf_len = FW_PHY_ACT_REQ_LEN;
414 hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
415 hic.cmd.port_number = hw->bus.lan_id;
416 hic.cmd.activity_id = IXGBE_CPU_TO_LE16(activity);
417 for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
418 hic.cmd.data[i] = IXGBE_CPU_TO_BE32((*data)[i]);
420 rc = ixgbe_host_interface_command(hw, (u32 *)&hic.cmd,
422 IXGBE_HI_COMMAND_TIMEOUT,
424 if (rc != IXGBE_SUCCESS)
426 if (hic.rsp.hdr.cmd_or_resp.ret_status ==
427 FW_CEM_RESP_STATUS_SUCCESS) {
428 for (i = 0; i < FW_PHY_ACT_DATA_COUNT; ++i)
429 (*data)[i] = IXGBE_BE32_TO_CPU(hic.rsp.data[i]);
430 return IXGBE_SUCCESS;
434 } while (retries > 0);
436 return IXGBE_ERR_HOST_INTERFACE_COMMAND;
439 static const struct {
441 ixgbe_link_speed phy_speed;
443 { FW_PHY_ACT_LINK_SPEED_10, IXGBE_LINK_SPEED_10_FULL },
444 { FW_PHY_ACT_LINK_SPEED_100, IXGBE_LINK_SPEED_100_FULL },
445 { FW_PHY_ACT_LINK_SPEED_1G, IXGBE_LINK_SPEED_1GB_FULL },
446 { FW_PHY_ACT_LINK_SPEED_2_5G, IXGBE_LINK_SPEED_2_5GB_FULL },
447 { FW_PHY_ACT_LINK_SPEED_5G, IXGBE_LINK_SPEED_5GB_FULL },
448 { FW_PHY_ACT_LINK_SPEED_10G, IXGBE_LINK_SPEED_10GB_FULL },
452 * ixgbe_get_phy_id_fw - Get the phy ID via firmware command
453 * @hw: pointer to hardware structure
457 static s32 ixgbe_get_phy_id_fw(struct ixgbe_hw *hw)
459 u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
465 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_PHY_INFO, &info);
469 hw->phy.speeds_supported = 0;
470 phy_speeds = info[0] & FW_PHY_INFO_SPEED_MASK;
471 for (i = 0; i < sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
472 if (phy_speeds & ixgbe_fw_map[i].fw_speed)
473 hw->phy.speeds_supported |= ixgbe_fw_map[i].phy_speed;
475 if (!hw->phy.autoneg_advertised)
476 hw->phy.autoneg_advertised = hw->phy.speeds_supported;
478 hw->phy.id = info[0] & FW_PHY_INFO_ID_HI_MASK;
479 phy_id_lo = info[1] & FW_PHY_INFO_ID_LO_MASK;
480 hw->phy.id |= phy_id_lo & IXGBE_PHY_REVISION_MASK;
481 hw->phy.revision = phy_id_lo & ~IXGBE_PHY_REVISION_MASK;
482 if (!hw->phy.id || hw->phy.id == IXGBE_PHY_REVISION_MASK)
483 return IXGBE_ERR_PHY_ADDR_INVALID;
484 return IXGBE_SUCCESS;
488 * ixgbe_identify_phy_fw - Get PHY type based on firmware command
489 * @hw: pointer to hardware structure
493 static s32 ixgbe_identify_phy_fw(struct ixgbe_hw *hw)
496 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY1_SM;
498 hw->phy.phy_semaphore_mask = IXGBE_GSSR_PHY0_SM;
500 hw->phy.type = ixgbe_phy_fw;
501 hw->phy.ops.read_reg = NULL;
502 hw->phy.ops.write_reg = NULL;
503 return ixgbe_get_phy_id_fw(hw);
507 * ixgbe_shutdown_fw_phy - Shutdown a firmware-controlled PHY
508 * @hw: pointer to hardware structure
512 s32 ixgbe_shutdown_fw_phy(struct ixgbe_hw *hw)
514 u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
516 setup[0] = FW_PHY_ACT_FORCE_LINK_DOWN_OFF;
517 return ixgbe_fw_phy_activity(hw, FW_PHY_ACT_FORCE_LINK_DOWN, &setup);
520 STATIC s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
521 u32 device_type, u16 *phy_data)
523 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
524 return IXGBE_NOT_IMPLEMENTED;
527 STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
528 u32 device_type, u16 phy_data)
530 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
531 return IXGBE_NOT_IMPLEMENTED;
535 * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
536 * @hw: pointer to the hardware structure
537 * @addr: I2C bus address to read from
538 * @reg: I2C device register to read from
539 * @val: pointer to location to receive read value
541 * Returns an error code on error.
543 STATIC s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
546 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
550 * ixgbe_read_i2c_combined_generic_unlocked - Do I2C read combined operation
551 * @hw: pointer to the hardware structure
552 * @addr: I2C bus address to read from
553 * @reg: I2C device register to read from
554 * @val: pointer to location to receive read value
556 * Returns an error code on error.
559 ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
562 return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, false);
566 * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
567 * @hw: pointer to the hardware structure
568 * @addr: I2C bus address to write to
569 * @reg: I2C device register to write to
570 * @val: value to write
572 * Returns an error code on error.
574 STATIC s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
575 u8 addr, u16 reg, u16 val)
577 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
581 * ixgbe_write_i2c_combined_generic_unlocked - Do I2C write combined operation
582 * @hw: pointer to the hardware structure
583 * @addr: I2C bus address to write to
584 * @reg: I2C device register to write to
585 * @val: value to write
587 * Returns an error code on error.
590 ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
591 u8 addr, u16 reg, u16 val)
593 return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, false);
597 * ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
598 * @hw: pointer to hardware structure
600 * Initialize the function pointers and for MAC type X550EM.
601 * Does not touch the hardware.
603 s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
605 struct ixgbe_mac_info *mac = &hw->mac;
606 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
607 struct ixgbe_phy_info *phy = &hw->phy;
610 DEBUGFUNC("ixgbe_init_ops_X550EM");
612 /* Similar to X550 so start there. */
613 ret_val = ixgbe_init_ops_X550(hw);
615 /* Since this function eventually calls
616 * ixgbe_init_ops_540 by design, we are setting
617 * the pointers to NULL explicitly here to overwrite
618 * the values being set in the x540 function.
620 /* Thermal sensor not supported in x550EM */
621 mac->ops.get_thermal_sensor_data = NULL;
622 mac->ops.init_thermal_sensor_thresh = NULL;
623 mac->thermal_sensor_enabled = false;
625 /* FCOE not supported in x550EM */
626 mac->ops.get_san_mac_addr = NULL;
627 mac->ops.set_san_mac_addr = NULL;
628 mac->ops.get_wwn_prefix = NULL;
629 mac->ops.get_fcoe_boot_status = NULL;
631 /* IPsec not supported in x550EM */
632 mac->ops.disable_sec_rx_path = NULL;
633 mac->ops.enable_sec_rx_path = NULL;
635 /* AUTOC register is not present in x550EM. */
636 mac->ops.prot_autoc_read = NULL;
637 mac->ops.prot_autoc_write = NULL;
639 /* X550EM bus type is internal*/
640 hw->bus.type = ixgbe_bus_type_internal;
641 mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
644 mac->ops.get_media_type = ixgbe_get_media_type_X550em;
645 mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
646 mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
647 mac->ops.reset_hw = ixgbe_reset_hw_X550em;
648 mac->ops.get_supported_physical_layer =
649 ixgbe_get_supported_physical_layer_X550em;
651 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
652 mac->ops.setup_fc = ixgbe_setup_fc_generic;
654 mac->ops.setup_fc = ixgbe_setup_fc_X550em;
657 phy->ops.init = ixgbe_init_phy_ops_X550em;
658 switch (hw->device_id) {
659 case IXGBE_DEV_ID_X550EM_A_1G_T:
660 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
661 mac->ops.setup_fc = NULL;
662 phy->ops.identify = ixgbe_identify_phy_fw;
663 phy->ops.set_phy_power = NULL;
664 phy->ops.get_firmware_version = NULL;
666 case IXGBE_DEV_ID_X550EM_X_1G_T:
667 mac->ops.setup_fc = NULL;
668 phy->ops.identify = ixgbe_identify_phy_x550em;
669 phy->ops.set_phy_power = NULL;
672 phy->ops.identify = ixgbe_identify_phy_x550em;
675 if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
676 phy->ops.set_phy_power = NULL;
680 eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
681 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
682 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
683 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
684 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
685 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
686 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
687 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
693 * ixgbe_setup_fw_link - Setup firmware-controlled PHYs
694 * @hw: pointer to hardware structure
696 static s32 ixgbe_setup_fw_link(struct ixgbe_hw *hw)
698 u32 setup[FW_PHY_ACT_DATA_COUNT] = { 0 };
702 if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
705 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
706 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
707 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
708 return IXGBE_ERR_INVALID_LINK_SETTINGS;
711 switch (hw->fc.requested_mode) {
713 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RXTX <<
714 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
716 case ixgbe_fc_rx_pause:
717 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_RX <<
718 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
720 case ixgbe_fc_tx_pause:
721 setup[0] |= FW_PHY_ACT_SETUP_LINK_PAUSE_TX <<
722 FW_PHY_ACT_SETUP_LINK_PAUSE_SHIFT;
728 for (i = 0; i < sizeof(ixgbe_fw_map) / sizeof(ixgbe_fw_map[0]); ++i) {
729 if (hw->phy.autoneg_advertised & ixgbe_fw_map[i].phy_speed)
730 setup[0] |= ixgbe_fw_map[i].fw_speed;
732 setup[0] |= FW_PHY_ACT_SETUP_LINK_HP | FW_PHY_ACT_SETUP_LINK_AN;
734 if (hw->phy.eee_speeds_advertised)
735 setup[0] |= FW_PHY_ACT_SETUP_LINK_EEE;
737 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_SETUP_LINK, &setup);
740 if (setup[0] == FW_PHY_ACT_SETUP_LINK_RSP_DOWN)
741 return IXGBE_ERR_OVERTEMP;
742 return IXGBE_SUCCESS;
746 * ixgbe_fc_autoneg_fw _ Set up flow control for FW-controlled PHYs
747 * @hw: pointer to hardware structure
749 * Called at init time to set up flow control.
751 static s32 ixgbe_fc_autoneg_fw(struct ixgbe_hw *hw)
753 if (hw->fc.requested_mode == ixgbe_fc_default)
754 hw->fc.requested_mode = ixgbe_fc_full;
756 return ixgbe_setup_fw_link(hw);
760 * ixgbe_setup_eee_fw - Enable/disable EEE support
761 * @hw: pointer to the HW structurewrite_reg_mdi
762 * @enable_eee: boolean flag to enable EEE
764 * Enable/disable EEE based on enable_eee flag.
765 * This function controls EEE for firmware-based PHY implementations.
767 static s32 ixgbe_setup_eee_fw(struct ixgbe_hw *hw, bool enable_eee)
769 if (!!hw->phy.eee_speeds_advertised == enable_eee)
770 return IXGBE_SUCCESS;
772 hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
774 hw->phy.eee_speeds_advertised = 0;
775 return hw->phy.ops.setup_link(hw);
779 * ixgbe_init_ops_X550EM_a - Inits func ptrs and MAC type
780 * @hw: pointer to hardware structure
782 * Initialize the function pointers and for MAC type X550EM_a.
783 * Does not touch the hardware.
785 s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw)
787 struct ixgbe_mac_info *mac = &hw->mac;
790 DEBUGFUNC("ixgbe_init_ops_X550EM_a");
792 /* Start with generic X550EM init */
793 ret_val = ixgbe_init_ops_X550EM(hw);
795 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
796 hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L) {
797 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
798 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
800 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a;
801 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a;
803 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
804 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
806 switch (mac->ops.get_media_type(hw)) {
807 case ixgbe_media_type_fiber:
808 mac->ops.setup_fc = NULL;
809 mac->ops.fc_autoneg = ixgbe_fc_autoneg_fiber_x550em_a;
811 case ixgbe_media_type_backplane:
812 mac->ops.fc_autoneg = ixgbe_fc_autoneg_backplane_x550em_a;
813 mac->ops.setup_fc = ixgbe_setup_fc_backplane_x550em_a;
819 switch (hw->device_id) {
820 case IXGBE_DEV_ID_X550EM_A_1G_T:
821 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
822 mac->ops.fc_autoneg = ixgbe_fc_autoneg_sgmii_x550em_a;
823 mac->ops.setup_fc = ixgbe_fc_autoneg_fw;
824 mac->ops.setup_eee = ixgbe_setup_eee_fw;
825 hw->phy.eee_speeds_supported = IXGBE_LINK_SPEED_100_FULL |
826 IXGBE_LINK_SPEED_1GB_FULL;
827 hw->phy.eee_speeds_advertised = hw->phy.eee_speeds_supported;
837 * ixgbe_init_ops_X550EM_x - Inits func ptrs and MAC type
838 * @hw: pointer to hardware structure
840 * Initialize the function pointers and for MAC type X550EM_x.
841 * Does not touch the hardware.
843 s32 ixgbe_init_ops_X550EM_x(struct ixgbe_hw *hw)
845 struct ixgbe_mac_info *mac = &hw->mac;
846 struct ixgbe_link_info *link = &hw->link;
849 DEBUGFUNC("ixgbe_init_ops_X550EM_x");
851 /* Start with generic X550EM init */
852 ret_val = ixgbe_init_ops_X550EM(hw);
854 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
855 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
856 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
857 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
858 link->ops.read_link = ixgbe_read_i2c_combined_generic;
859 link->ops.read_link_unlocked = ixgbe_read_i2c_combined_generic_unlocked;
860 link->ops.write_link = ixgbe_write_i2c_combined_generic;
861 link->ops.write_link_unlocked =
862 ixgbe_write_i2c_combined_generic_unlocked;
863 link->addr = IXGBE_CS4227;
865 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_1G_T) {
866 mac->ops.setup_fc = NULL;
867 mac->ops.setup_eee = NULL;
868 mac->ops.init_led_link_act = NULL;
875 * ixgbe_dmac_config_X550
876 * @hw: pointer to hardware structure
878 * Configure DMA coalescing. If enabling dmac, dmac is activated.
879 * When disabling dmac, dmac enable dmac bit is cleared.
881 s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
883 u32 reg, high_pri_tc;
885 DEBUGFUNC("ixgbe_dmac_config_X550");
887 /* Disable DMA coalescing before configuring */
888 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
889 reg &= ~IXGBE_DMACR_DMAC_EN;
890 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
892 /* Disable DMA Coalescing if the watchdog timer is 0 */
893 if (!hw->mac.dmac_config.watchdog_timer)
896 ixgbe_dmac_config_tcs_X550(hw);
898 /* Configure DMA Coalescing Control Register */
899 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
901 /* Set the watchdog timer in units of 40.96 usec */
902 reg &= ~IXGBE_DMACR_DMACWT_MASK;
903 reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
905 reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
906 /* If fcoe is enabled, set high priority traffic class */
907 if (hw->mac.dmac_config.fcoe_en) {
908 high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
909 reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
910 IXGBE_DMACR_HIGH_PRI_TC_MASK);
912 reg |= IXGBE_DMACR_EN_MNG_IND;
914 /* Enable DMA coalescing after configuration */
915 reg |= IXGBE_DMACR_DMAC_EN;
916 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
919 return IXGBE_SUCCESS;
923 * ixgbe_dmac_config_tcs_X550
924 * @hw: pointer to hardware structure
926 * Configure DMA coalescing threshold per TC. The dmac enable bit must
927 * be cleared before configuring.
929 s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
931 u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
933 DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
935 /* Configure DMA coalescing enabled */
936 switch (hw->mac.dmac_config.link_speed) {
937 case IXGBE_LINK_SPEED_10_FULL:
938 case IXGBE_LINK_SPEED_100_FULL:
939 pb_headroom = IXGBE_DMACRXT_100M;
941 case IXGBE_LINK_SPEED_1GB_FULL:
942 pb_headroom = IXGBE_DMACRXT_1G;
945 pb_headroom = IXGBE_DMACRXT_10G;
949 maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
950 IXGBE_MHADD_MFS_SHIFT) / 1024);
952 /* Set the per Rx packet buffer receive threshold */
953 for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
954 reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
955 reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
957 if (tc < hw->mac.dmac_config.num_tcs) {
959 rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
960 rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
961 IXGBE_RXPBSIZE_SHIFT;
963 /* Calculate receive buffer threshold in kilobytes */
964 if (rx_pb_size > pb_headroom)
965 rx_pb_size = rx_pb_size - pb_headroom;
969 /* Minimum of MFS shall be set for DMCTH */
970 reg |= (rx_pb_size > maxframe_size_kb) ?
971 rx_pb_size : maxframe_size_kb;
973 IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
975 return IXGBE_SUCCESS;
979 * ixgbe_dmac_update_tcs_X550
980 * @hw: pointer to hardware structure
982 * Disables dmac, updates per TC settings, and then enables dmac.
984 s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
988 DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
990 /* Disable DMA coalescing before configuring */
991 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
992 reg &= ~IXGBE_DMACR_DMAC_EN;
993 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
995 ixgbe_dmac_config_tcs_X550(hw);
997 /* Enable DMA coalescing after configuration */
998 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
999 reg |= IXGBE_DMACR_DMAC_EN;
1000 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
1002 return IXGBE_SUCCESS;
1006 * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
1007 * @hw: pointer to hardware structure
1009 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
1010 * ixgbe_hw struct in order to set up EEPROM access.
1012 s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
1014 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
1018 DEBUGFUNC("ixgbe_init_eeprom_params_X550");
1020 if (eeprom->type == ixgbe_eeprom_uninitialized) {
1021 eeprom->semaphore_delay = 10;
1022 eeprom->type = ixgbe_flash;
1024 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
1025 eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
1026 IXGBE_EEC_SIZE_SHIFT);
1027 eeprom->word_size = 1 << (eeprom_size +
1028 IXGBE_EEPROM_WORD_SIZE_SHIFT);
1030 DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
1031 eeprom->type, eeprom->word_size);
1034 return IXGBE_SUCCESS;
1038 * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
1039 * @hw: pointer to hardware structure
1040 * @enable: enable or disable source address pruning
1041 * @pool: Rx pool to set source address pruning for
1043 void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
1048 /* max rx pool is 63 */
1052 pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
1053 pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
1056 pfflp |= (1ULL << pool);
1058 pfflp &= ~(1ULL << pool);
1060 IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
1061 IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
1065 * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
1066 * @hw: pointer to hardware structure
1067 * @enable: enable or disable switch for Ethertype anti-spoofing
1068 * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
1071 void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
1072 bool enable, int vf)
1074 int vf_target_reg = vf >> 3;
1075 int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
1078 DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
1080 pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
1082 pfvfspoof |= (1 << vf_target_shift);
1084 pfvfspoof &= ~(1 << vf_target_shift);
1086 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
1090 * ixgbe_iosf_wait - Wait for IOSF command completion
1091 * @hw: pointer to hardware structure
1092 * @ctrl: pointer to location to receive final IOSF control value
1094 * Returns failing status on timeout
1096 * Note: ctrl can be NULL if the IOSF control register value is not needed
1098 STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
1102 /* Check every 10 usec to see if the address cycle completed.
1103 * The SB IOSF BUSY bit will clear when the operation is
1106 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
1107 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
1108 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
1114 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
1115 ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
1116 return IXGBE_ERR_PHY;
1119 return IXGBE_SUCCESS;
1123 * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register
1124 * of the IOSF device
1125 * @hw: pointer to hardware structure
1126 * @reg_addr: 32 bit PHY register to write
1127 * @device_type: 3 bit device type
1128 * @data: Data to write to the register
1130 s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
1131 u32 device_type, u32 data)
1133 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
1137 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
1138 if (ret != IXGBE_SUCCESS)
1141 ret = ixgbe_iosf_wait(hw, NULL);
1142 if (ret != IXGBE_SUCCESS)
1145 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
1146 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
1148 /* Write IOSF control register */
1149 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
1151 /* Write IOSF data register */
1152 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
1154 ret = ixgbe_iosf_wait(hw, &command);
1156 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
1157 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
1158 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
1159 ERROR_REPORT2(IXGBE_ERROR_POLLING,
1160 "Failed to write, error %x\n", error);
1161 ret = IXGBE_ERR_PHY;
1165 ixgbe_release_swfw_semaphore(hw, gssr);
1170 * ixgbe_read_iosf_sb_reg_x550 - Reads specified register of the IOSF device
1171 * @hw: pointer to hardware structure
1172 * @reg_addr: 32 bit PHY register to write
1173 * @device_type: 3 bit device type
1174 * @data: Pointer to read data from the register
1176 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
1177 u32 device_type, u32 *data)
1179 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
1183 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
1184 if (ret != IXGBE_SUCCESS)
1187 ret = ixgbe_iosf_wait(hw, NULL);
1188 if (ret != IXGBE_SUCCESS)
1191 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
1192 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
1194 /* Write IOSF control register */
1195 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
1197 ret = ixgbe_iosf_wait(hw, &command);
1199 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
1200 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
1201 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
1202 ERROR_REPORT2(IXGBE_ERROR_POLLING,
1203 "Failed to read, error %x\n", error);
1204 ret = IXGBE_ERR_PHY;
1207 if (ret == IXGBE_SUCCESS)
1208 *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
1211 ixgbe_release_swfw_semaphore(hw, gssr);
1216 * ixgbe_get_phy_token - Get the token for shared phy access
1217 * @hw: Pointer to hardware structure
1220 s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
1222 struct ixgbe_hic_phy_token_req token_cmd;
1225 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
1226 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
1227 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
1228 token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1229 token_cmd.port_number = hw->bus.lan_id;
1230 token_cmd.command_type = FW_PHY_TOKEN_REQ;
1232 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
1234 IXGBE_HI_COMMAND_TIMEOUT,
1237 DEBUGOUT1("Issuing host interface command failed with Status = %d\n",
1241 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
1242 return IXGBE_SUCCESS;
1243 if (token_cmd.hdr.cmd_or_resp.ret_status != FW_PHY_TOKEN_RETRY) {
1244 DEBUGOUT1("Host interface command returned 0x%08x , returning IXGBE_ERR_FW_RESP_INVALID\n",
1245 token_cmd.hdr.cmd_or_resp.ret_status);
1246 return IXGBE_ERR_FW_RESP_INVALID;
1249 DEBUGOUT("Returning IXGBE_ERR_TOKEN_RETRY\n");
1250 return IXGBE_ERR_TOKEN_RETRY;
1254 * ixgbe_put_phy_token - Put the token for shared phy access
1255 * @hw: Pointer to hardware structure
1258 s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
1260 struct ixgbe_hic_phy_token_req token_cmd;
1263 token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
1264 token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
1265 token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
1266 token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1267 token_cmd.port_number = hw->bus.lan_id;
1268 token_cmd.command_type = FW_PHY_TOKEN_REL;
1270 status = ixgbe_host_interface_command(hw, (u32 *)&token_cmd,
1272 IXGBE_HI_COMMAND_TIMEOUT,
1276 if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
1277 return IXGBE_SUCCESS;
1279 DEBUGOUT("Put PHY Token host interface command failed");
1280 return IXGBE_ERR_FW_RESP_INVALID;
1284 * ixgbe_write_iosf_sb_reg_x550a - Writes a value to specified register
1285 * of the IOSF device
1286 * @hw: pointer to hardware structure
1287 * @reg_addr: 32 bit PHY register to write
1288 * @device_type: 3 bit device type
1289 * @data: Data to write to the register
1291 s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1292 u32 device_type, u32 data)
1294 struct ixgbe_hic_internal_phy_req write_cmd;
1296 UNREFERENCED_1PARAMETER(device_type);
1298 memset(&write_cmd, 0, sizeof(write_cmd));
1299 write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1300 write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1301 write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1302 write_cmd.port_number = hw->bus.lan_id;
1303 write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
1304 write_cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
1305 write_cmd.write_data = IXGBE_CPU_TO_BE32(data);
1307 status = ixgbe_host_interface_command(hw, (u32 *)&write_cmd,
1309 IXGBE_HI_COMMAND_TIMEOUT, false);
1315 * ixgbe_read_iosf_sb_reg_x550a - Reads specified register of the IOSF device
1316 * @hw: pointer to hardware structure
1317 * @reg_addr: 32 bit PHY register to write
1318 * @device_type: 3 bit device type
1319 * @data: Pointer to read data from the register
1321 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
1322 u32 device_type, u32 *data)
1325 struct ixgbe_hic_internal_phy_req cmd;
1326 struct ixgbe_hic_internal_phy_resp rsp;
1329 UNREFERENCED_1PARAMETER(device_type);
1331 memset(&hic, 0, sizeof(hic));
1332 hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
1333 hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
1334 hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
1335 hic.cmd.port_number = hw->bus.lan_id;
1336 hic.cmd.command_type = FW_INT_PHY_REQ_READ;
1337 hic.cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
1339 status = ixgbe_host_interface_command(hw, (u32 *)&hic.cmd,
1341 IXGBE_HI_COMMAND_TIMEOUT, true);
1343 /* Extract the register value from the response. */
1344 *data = IXGBE_BE32_TO_CPU(hic.rsp.read_data);
1350 * ixgbe_disable_mdd_X550
1351 * @hw: pointer to hardware structure
1353 * Disable malicious driver detection
1355 void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
1359 DEBUGFUNC("ixgbe_disable_mdd_X550");
1361 /* Disable MDD for TX DMA and interrupt */
1362 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1363 reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1364 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1366 /* Disable MDD for RX and interrupt */
1367 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1368 reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1369 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1373 * ixgbe_enable_mdd_X550
1374 * @hw: pointer to hardware structure
1376 * Enable malicious driver detection
1378 void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
1382 DEBUGFUNC("ixgbe_enable_mdd_X550");
1384 /* Enable MDD for TX DMA and interrupt */
1385 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
1386 reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
1387 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
1389 /* Enable MDD for RX and interrupt */
1390 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
1391 reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
1392 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
1396 * ixgbe_restore_mdd_vf_X550
1397 * @hw: pointer to hardware structure
1400 * Restore VF that was disabled during malicious driver detection event
1402 void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
1404 u32 idx, reg, num_qs, start_q, bitmask;
1406 DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
1408 /* Map VF to queues */
1409 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1410 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1411 case IXGBE_MRQC_VMDQRT8TCEN:
1412 num_qs = 8; /* 16 VFs / pools */
1413 bitmask = 0x000000FF;
1415 case IXGBE_MRQC_VMDQRSS32EN:
1416 case IXGBE_MRQC_VMDQRT4TCEN:
1417 num_qs = 4; /* 32 VFs / pools */
1418 bitmask = 0x0000000F;
1420 default: /* 64 VFs / pools */
1422 bitmask = 0x00000003;
1425 start_q = vf * num_qs;
1427 /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
1430 reg |= (bitmask << (start_q % 32));
1431 IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
1432 IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
1436 * ixgbe_mdd_event_X550
1437 * @hw: pointer to hardware structure
1438 * @vf_bitmap: vf bitmap of malicious vfs
1440 * Handle malicious driver detection event.
1442 void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
1445 u32 i, j, reg, q, shift, vf, idx;
1447 DEBUGFUNC("ixgbe_mdd_event_X550");
1449 /* figure out pool size for mapping to vf's */
1450 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1451 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1452 case IXGBE_MRQC_VMDQRT8TCEN:
1453 shift = 3; /* 16 VFs / pools */
1455 case IXGBE_MRQC_VMDQRSS32EN:
1456 case IXGBE_MRQC_VMDQRT4TCEN:
1457 shift = 2; /* 32 VFs / pools */
1460 shift = 1; /* 64 VFs / pools */
1464 /* Read WQBR_TX and WQBR_RX and check for malicious queues */
1465 for (i = 0; i < 4; i++) {
1466 wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
1467 wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
1472 /* Get malicious queue */
1473 for (j = 0; j < 32 && wqbr; j++) {
1475 if (!(wqbr & (1 << j)))
1478 /* Get queue from bitmask */
1481 /* Map queue to vf */
1484 /* Set vf bit in vf_bitmap */
1486 vf_bitmap[idx] |= (1 << (vf % 32));
1493 * ixgbe_get_media_type_X550em - Get media type
1494 * @hw: pointer to hardware structure
1496 * Returns the media type (fiber, copper, backplane)
1498 enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1500 enum ixgbe_media_type media_type;
1502 DEBUGFUNC("ixgbe_get_media_type_X550em");
1504 /* Detect if there is a copper PHY attached. */
1505 switch (hw->device_id) {
1506 case IXGBE_DEV_ID_X550EM_X_KR:
1507 case IXGBE_DEV_ID_X550EM_X_KX4:
1508 case IXGBE_DEV_ID_X550EM_X_XFI:
1509 case IXGBE_DEV_ID_X550EM_A_KR:
1510 case IXGBE_DEV_ID_X550EM_A_KR_L:
1511 media_type = ixgbe_media_type_backplane;
1513 case IXGBE_DEV_ID_X550EM_X_SFP:
1514 case IXGBE_DEV_ID_X550EM_A_SFP:
1515 case IXGBE_DEV_ID_X550EM_A_SFP_N:
1516 case IXGBE_DEV_ID_X550EM_A_QSFP:
1517 case IXGBE_DEV_ID_X550EM_A_QSFP_N:
1518 media_type = ixgbe_media_type_fiber;
1520 case IXGBE_DEV_ID_X550EM_X_1G_T:
1521 case IXGBE_DEV_ID_X550EM_X_10G_T:
1522 case IXGBE_DEV_ID_X550EM_A_10G_T:
1523 media_type = ixgbe_media_type_copper;
1525 case IXGBE_DEV_ID_X550EM_A_SGMII:
1526 case IXGBE_DEV_ID_X550EM_A_SGMII_L:
1527 media_type = ixgbe_media_type_backplane;
1528 hw->phy.type = ixgbe_phy_sgmii;
1530 case IXGBE_DEV_ID_X550EM_A_1G_T:
1531 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
1532 media_type = ixgbe_media_type_copper;
1535 media_type = ixgbe_media_type_unknown;
1542 * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
1543 * @hw: pointer to hardware structure
1544 * @linear: true if SFP module is linear
1546 STATIC s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
1548 DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
1550 switch (hw->phy.sfp_type) {
1551 case ixgbe_sfp_type_not_present:
1552 return IXGBE_ERR_SFP_NOT_PRESENT;
1553 case ixgbe_sfp_type_da_cu_core0:
1554 case ixgbe_sfp_type_da_cu_core1:
1557 case ixgbe_sfp_type_srlr_core0:
1558 case ixgbe_sfp_type_srlr_core1:
1559 case ixgbe_sfp_type_da_act_lmt_core0:
1560 case ixgbe_sfp_type_da_act_lmt_core1:
1561 case ixgbe_sfp_type_1g_sx_core0:
1562 case ixgbe_sfp_type_1g_sx_core1:
1563 case ixgbe_sfp_type_1g_lx_core0:
1564 case ixgbe_sfp_type_1g_lx_core1:
1567 case ixgbe_sfp_type_unknown:
1568 case ixgbe_sfp_type_1g_cu_core0:
1569 case ixgbe_sfp_type_1g_cu_core1:
1571 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1574 return IXGBE_SUCCESS;
1578 * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
1579 * @hw: pointer to hardware structure
1581 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1583 s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
1588 DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
1590 status = ixgbe_identify_module_generic(hw);
1592 if (status != IXGBE_SUCCESS)
1595 /* Check if SFP module is supported */
1596 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1602 * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
1603 * @hw: pointer to hardware structure
1605 s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
1610 DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
1612 /* Check if SFP module is supported */
1613 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1615 if (status != IXGBE_SUCCESS)
1618 ixgbe_init_mac_link_ops_X550em(hw);
1619 hw->phy.ops.reset = NULL;
1621 return IXGBE_SUCCESS;
1625 * ixgbe_restart_an_internal_phy_x550em - restart autonegotiation for the
1627 * @hw: pointer to hardware structure
1629 STATIC s32 ixgbe_restart_an_internal_phy_x550em(struct ixgbe_hw *hw)
1634 /* Restart auto-negotiation. */
1635 status = hw->mac.ops.read_iosf_sb_reg(hw,
1636 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1637 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_ctrl);
1640 DEBUGOUT("Auto-negotiation did not complete\n");
1644 link_ctrl |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1645 status = hw->mac.ops.write_iosf_sb_reg(hw,
1646 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1647 IXGBE_SB_IOSF_TARGET_KR_PHY, link_ctrl);
1649 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1652 /* Indicate to FW that AN restart has been asserted */
1653 status = hw->mac.ops.read_iosf_sb_reg(hw,
1654 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1655 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_mask_st20);
1658 DEBUGOUT("Auto-negotiation did not complete\n");
1662 flx_mask_st20 |= IXGBE_KRM_PMD_FLX_MASK_ST20_FW_AN_RESTART;
1663 status = hw->mac.ops.write_iosf_sb_reg(hw,
1664 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1665 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_mask_st20);
1671 #ifndef PREBOOT_SUPPORT
1673 * ixgbe_setup_sgmii - Set up link for sgmii
1674 * @hw: pointer to hardware structure
1675 * @speed: new link speed
1676 * @autoneg_wait: true when waiting for completion is needed
1678 STATIC s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
1681 struct ixgbe_mac_info *mac = &hw->mac;
1682 u32 lval, sval, flx_val;
1685 rc = mac->ops.read_iosf_sb_reg(hw,
1686 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1687 IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
1691 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1692 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1693 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
1694 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
1695 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1696 rc = mac->ops.write_iosf_sb_reg(hw,
1697 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1698 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1702 rc = mac->ops.read_iosf_sb_reg(hw,
1703 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1704 IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
1708 sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
1709 sval |= IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
1710 rc = mac->ops.write_iosf_sb_reg(hw,
1711 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1712 IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
1716 rc = mac->ops.read_iosf_sb_reg(hw,
1717 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1718 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
1722 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
1723 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
1724 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
1725 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
1726 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
1728 rc = mac->ops.write_iosf_sb_reg(hw,
1729 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1730 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
1734 rc = ixgbe_restart_an_internal_phy_x550em(hw);
1738 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
1741 #endif /* PREBOOT_SUPPORT */
1743 * ixgbe_setup_sgmii_fw - Set up link for internal PHY SGMII auto-negotiation
1744 * @hw: pointer to hardware structure
1745 * @speed: new link speed
1746 * @autoneg_wait: true when waiting for completion is needed
1748 STATIC s32 ixgbe_setup_sgmii_fw(struct ixgbe_hw *hw, ixgbe_link_speed speed,
1751 struct ixgbe_mac_info *mac = &hw->mac;
1752 u32 lval, sval, flx_val;
1755 rc = mac->ops.read_iosf_sb_reg(hw,
1756 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1757 IXGBE_SB_IOSF_TARGET_KR_PHY, &lval);
1761 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1762 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1763 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN;
1764 lval |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN;
1765 lval &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1766 rc = mac->ops.write_iosf_sb_reg(hw,
1767 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1768 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1772 rc = mac->ops.read_iosf_sb_reg(hw,
1773 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1774 IXGBE_SB_IOSF_TARGET_KR_PHY, &sval);
1778 sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D;
1779 sval &= ~IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D;
1780 rc = mac->ops.write_iosf_sb_reg(hw,
1781 IXGBE_KRM_SGMII_CTRL(hw->bus.lan_id),
1782 IXGBE_SB_IOSF_TARGET_KR_PHY, sval);
1786 rc = mac->ops.write_iosf_sb_reg(hw,
1787 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1788 IXGBE_SB_IOSF_TARGET_KR_PHY, lval);
1792 rc = mac->ops.read_iosf_sb_reg(hw,
1793 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1794 IXGBE_SB_IOSF_TARGET_KR_PHY, &flx_val);
1798 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
1799 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
1800 flx_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
1801 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
1802 flx_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
1804 rc = mac->ops.write_iosf_sb_reg(hw,
1805 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
1806 IXGBE_SB_IOSF_TARGET_KR_PHY, flx_val);
1810 rc = ixgbe_restart_an_internal_phy_x550em(hw);
1812 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait);
1816 * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
1817 * @hw: pointer to hardware structure
1819 void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
1821 struct ixgbe_mac_info *mac = &hw->mac;
1823 DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
1825 switch (hw->mac.ops.get_media_type(hw)) {
1826 case ixgbe_media_type_fiber:
1827 /* CS4227 does not support autoneg, so disable the laser control
1828 * functions for SFP+ fiber
1830 mac->ops.disable_tx_laser = NULL;
1831 mac->ops.enable_tx_laser = NULL;
1832 mac->ops.flap_tx_laser = NULL;
1833 mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
1834 mac->ops.set_rate_select_speed =
1835 ixgbe_set_soft_rate_select_speed;
1837 if ((hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) ||
1838 (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP))
1839 mac->ops.setup_mac_link =
1840 ixgbe_setup_mac_link_sfp_x550a;
1842 mac->ops.setup_mac_link =
1843 ixgbe_setup_mac_link_sfp_x550em;
1845 case ixgbe_media_type_copper:
1846 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_1G_T)
1848 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1849 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T ||
1850 hw->device_id == IXGBE_DEV_ID_X550EM_A_1G_T_L) {
1851 mac->ops.setup_link = ixgbe_setup_sgmii_fw;
1852 mac->ops.check_link =
1853 ixgbe_check_mac_link_generic;
1855 mac->ops.setup_link =
1856 ixgbe_setup_mac_link_t_X550em;
1859 mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
1860 mac->ops.check_link = ixgbe_check_link_t_X550em;
1863 case ixgbe_media_type_backplane:
1864 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
1865 hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
1866 #ifdef PREBOOT_SUPPORT
1867 mac->ops.setup_link = ixgbe_setup_sgmii_fw;
1869 mac->ops.setup_link = ixgbe_setup_sgmii;
1870 #endif /* PREBOOT_SUPPORT */
1878 * ixgbe_get_link_capabilities_x550em - Determines link capabilities
1879 * @hw: pointer to hardware structure
1880 * @speed: pointer to link speed
1881 * @autoneg: true when autoneg or autotry is enabled
1883 s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
1884 ixgbe_link_speed *speed,
1887 DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
1890 if (hw->phy.type == ixgbe_phy_fw) {
1892 *speed = hw->phy.speeds_supported;
1897 if (hw->phy.media_type == ixgbe_media_type_fiber) {
1899 /* CS4227 SFP must not enable auto-negotiation */
1902 /* Check if 1G SFP module. */
1903 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1904 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
1905 || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1906 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
1907 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1908 return IXGBE_SUCCESS;
1911 /* Link capabilities are based on SFP */
1912 if (hw->phy.multispeed_fiber)
1913 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1914 IXGBE_LINK_SPEED_1GB_FULL;
1916 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1918 switch (hw->phy.type) {
1919 case ixgbe_phy_ext_1g_t:
1920 #ifdef PREBOOT_SUPPORT
1921 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1923 #endif /* PREBOOT_SUPPORT */
1924 case ixgbe_phy_sgmii:
1925 #ifdef PREBOOT_SUPPORT
1926 *speed = IXGBE_LINK_SPEED_1GB_FULL |
1927 IXGBE_LINK_SPEED_100_FULL |
1928 IXGBE_LINK_SPEED_10_FULL;
1930 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1931 #endif /* PREBOOT_SUPPORT */
1933 case ixgbe_phy_x550em_kr:
1934 if (hw->mac.type == ixgbe_mac_X550EM_a) {
1935 /* check different backplane modes */
1936 if (hw->phy.nw_mng_if_sel &
1937 IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
1938 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
1940 } else if (hw->device_id ==
1941 IXGBE_DEV_ID_X550EM_A_KR_L) {
1942 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1948 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1949 IXGBE_LINK_SPEED_1GB_FULL;
1955 return IXGBE_SUCCESS;
1959 * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
1960 * @hw: pointer to hardware structure
1961 * @lsc: pointer to boolean flag which indicates whether external Base T
1962 * PHY interrupt is lsc
1964 * Determime if external Base T PHY interrupt cause is high temperature
1965 * failure alarm or link status change.
1967 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
1968 * failure alarm, else return PHY access status.
1970 STATIC s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
1977 /* Vendor alarm triggered */
1978 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1979 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1982 if (status != IXGBE_SUCCESS ||
1983 !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
1986 /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
1987 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
1988 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1991 if (status != IXGBE_SUCCESS ||
1992 !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1993 IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
1996 /* Global alarm triggered */
1997 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
1998 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2001 if (status != IXGBE_SUCCESS)
2004 /* If high temperature failure, then return over temp error and exit */
2005 if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
2006 /* power down the PHY in case the PHY FW didn't already */
2007 ixgbe_set_copper_phy_power(hw, false);
2008 return IXGBE_ERR_OVERTEMP;
2009 } else if (reg & IXGBE_MDIO_GLOBAL_ALM_1_DEV_FAULT) {
2010 /* device fault alarm triggered */
2011 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_FAULT_MSG,
2012 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2015 if (status != IXGBE_SUCCESS)
2018 /* if device fault was due to high temp alarm handle and exit */
2019 if (reg == IXGBE_MDIO_GLOBAL_FAULT_MSG_HI_TMP) {
2020 /* power down the PHY in case the PHY FW didn't */
2021 ixgbe_set_copper_phy_power(hw, false);
2022 return IXGBE_ERR_OVERTEMP;
2026 /* Vendor alarm 2 triggered */
2027 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
2028 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2030 if (status != IXGBE_SUCCESS ||
2031 !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
2034 /* link connect/disconnect event occurred */
2035 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
2036 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2038 if (status != IXGBE_SUCCESS)
2042 if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
2045 return IXGBE_SUCCESS;
2049 * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
2050 * @hw: pointer to hardware structure
2052 * Enable link status change and temperature failure alarm for the external
2055 * Returns PHY access status
2057 STATIC s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
2063 /* Clear interrupt flags */
2064 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
2066 /* Enable link status change alarm */
2068 /* Enable the LASI interrupts on X552 devices to receive notifications
2069 * of the link configurations of the external PHY and correspondingly
2070 * support the configuration of the internal iXFI link, since iXFI does
2071 * not support auto-negotiation. This is not required for X553 devices
2072 * having KR support, which performs auto-negotiations and which is used
2073 * as the internal link to the external PHY. Hence adding a check here
2074 * to avoid enabling LASI interrupts for X553 devices.
2076 if (hw->mac.type != ixgbe_mac_X550EM_a) {
2077 status = hw->phy.ops.read_reg(hw,
2078 IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
2079 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
2081 if (status != IXGBE_SUCCESS)
2084 reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
2086 status = hw->phy.ops.write_reg(hw,
2087 IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
2088 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
2090 if (status != IXGBE_SUCCESS)
2094 /* Enable high temperature failure and global fault alarms */
2095 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
2096 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2099 if (status != IXGBE_SUCCESS)
2102 reg |= (IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN |
2103 IXGBE_MDIO_GLOBAL_INT_DEV_FAULT_EN);
2105 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
2106 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2109 if (status != IXGBE_SUCCESS)
2112 /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
2113 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
2114 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2117 if (status != IXGBE_SUCCESS)
2120 reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
2121 IXGBE_MDIO_GLOBAL_ALARM_1_INT);
2123 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
2124 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2127 if (status != IXGBE_SUCCESS)
2130 /* Enable chip-wide vendor alarm */
2131 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
2132 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2135 if (status != IXGBE_SUCCESS)
2138 reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
2140 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
2141 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2148 * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
2149 * @hw: pointer to hardware structure
2150 * @speed: link speed
2152 * Configures the integrated KR PHY.
2154 STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
2155 ixgbe_link_speed speed)
2160 status = hw->mac.ops.read_iosf_sb_reg(hw,
2161 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2162 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2166 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2167 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
2168 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
2170 /* Advertise 10G support. */
2171 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
2172 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
2174 /* Advertise 1G support. */
2175 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
2176 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
2178 status = hw->mac.ops.write_iosf_sb_reg(hw,
2179 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2180 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2182 if (hw->mac.type == ixgbe_mac_X550EM_a) {
2183 /* Set lane mode to KR auto negotiation */
2184 status = hw->mac.ops.read_iosf_sb_reg(hw,
2185 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2186 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2191 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
2192 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_AN;
2193 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
2194 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
2195 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
2197 status = hw->mac.ops.write_iosf_sb_reg(hw,
2198 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2199 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2202 return ixgbe_restart_an_internal_phy_x550em(hw);
2206 * ixgbe_reset_phy_fw - Reset firmware-controlled PHYs
2207 * @hw: pointer to hardware structure
2209 static s32 ixgbe_reset_phy_fw(struct ixgbe_hw *hw)
2211 u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
2214 if (hw->phy.reset_disable || ixgbe_check_reset_blocked(hw))
2215 return IXGBE_SUCCESS;
2217 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_PHY_SW_RESET, &store);
2220 memset(store, 0, sizeof(store));
2222 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_INIT_PHY, &store);
2226 return ixgbe_setup_fw_link(hw);
2230 * ixgbe_check_overtemp_fw - Check firmware-controlled PHYs for overtemp
2231 * @hw: pointer to hardware structure
2233 static s32 ixgbe_check_overtemp_fw(struct ixgbe_hw *hw)
2235 u32 store[FW_PHY_ACT_DATA_COUNT] = { 0 };
2238 rc = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &store);
2242 if (store[0] & FW_PHY_ACT_GET_LINK_INFO_TEMP) {
2243 ixgbe_shutdown_fw_phy(hw);
2244 return IXGBE_ERR_OVERTEMP;
2246 return IXGBE_SUCCESS;
2250 * ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
2251 * @hw: pointer to hardware structure
2253 * Read NW_MNG_IF_SEL register and save field values, and check for valid field
2256 STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
2258 /* Save NW management interface connected on board. This is used
2259 * to determine internal PHY mode.
2261 hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
2263 /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
2264 * PHY address. This register field was has only been used for X552.
2266 if (hw->mac.type == ixgbe_mac_X550EM_a &&
2267 hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
2268 hw->phy.addr = (hw->phy.nw_mng_if_sel &
2269 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
2270 IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
2273 return IXGBE_SUCCESS;
2277 * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
2278 * @hw: pointer to hardware structure
2280 * Initialize any function pointers that were not able to be
2281 * set during init_shared_code because the PHY/SFP type was
2282 * not known. Perform the SFP init if necessary.
2284 s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
2286 struct ixgbe_phy_info *phy = &hw->phy;
2289 DEBUGFUNC("ixgbe_init_phy_ops_X550em");
2291 hw->mac.ops.set_lan_id(hw);
2292 ixgbe_read_mng_if_sel_x550em(hw);
2294 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
2295 phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
2296 ixgbe_setup_mux_ctl(hw);
2297 phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
2300 switch (hw->device_id) {
2301 case IXGBE_DEV_ID_X550EM_A_1G_T:
2302 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
2303 phy->ops.read_reg_mdi = NULL;
2304 phy->ops.write_reg_mdi = NULL;
2305 hw->phy.ops.read_reg = NULL;
2306 hw->phy.ops.write_reg = NULL;
2307 phy->ops.check_overtemp = ixgbe_check_overtemp_fw;
2309 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
2311 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
2314 case IXGBE_DEV_ID_X550EM_A_10G_T:
2315 case IXGBE_DEV_ID_X550EM_A_SFP:
2316 hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
2317 hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
2319 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
2321 hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY0_SM;
2323 case IXGBE_DEV_ID_X550EM_X_SFP:
2324 /* set up for CS4227 usage */
2325 hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
2327 case IXGBE_DEV_ID_X550EM_X_1G_T:
2328 phy->ops.read_reg_mdi = NULL;
2329 phy->ops.write_reg_mdi = NULL;
2334 /* Identify the PHY or SFP module */
2335 ret_val = phy->ops.identify(hw);
2336 if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED ||
2337 ret_val == IXGBE_ERR_PHY_ADDR_INVALID)
2340 /* Setup function pointers based on detected hardware */
2341 ixgbe_init_mac_link_ops_X550em(hw);
2342 if (phy->sfp_type != ixgbe_sfp_type_unknown)
2343 phy->ops.reset = NULL;
2345 /* Set functions pointers based on phy type */
2346 switch (hw->phy.type) {
2347 case ixgbe_phy_x550em_kx4:
2348 phy->ops.setup_link = NULL;
2349 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2350 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2352 case ixgbe_phy_x550em_kr:
2353 phy->ops.setup_link = ixgbe_setup_kr_x550em;
2354 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2355 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2357 case ixgbe_phy_ext_1g_t:
2358 /* link is managed by FW */
2359 phy->ops.setup_link = NULL;
2360 phy->ops.reset = NULL;
2362 case ixgbe_phy_x550em_xfi:
2363 /* link is managed by HW */
2364 phy->ops.setup_link = NULL;
2365 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
2366 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
2368 case ixgbe_phy_x550em_ext_t:
2369 /* If internal link mode is XFI, then setup iXFI internal link,
2370 * else setup KR now.
2372 phy->ops.setup_internal_link =
2373 ixgbe_setup_internal_phy_t_x550em;
2375 /* setup SW LPLU only for first revision of X550EM_x */
2376 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
2377 !(IXGBE_FUSES0_REV_MASK &
2378 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
2379 phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
2381 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
2382 phy->ops.reset = ixgbe_reset_phy_t_X550em;
2384 case ixgbe_phy_sgmii:
2385 phy->ops.setup_link = NULL;
2388 phy->ops.setup_link = ixgbe_setup_fw_link;
2389 phy->ops.reset = ixgbe_reset_phy_fw;
2398 * ixgbe_set_mdio_speed - Set MDIO clock speed
2399 * @hw: pointer to hardware structure
2401 STATIC void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)
2405 switch (hw->device_id) {
2406 case IXGBE_DEV_ID_X550EM_X_10G_T:
2407 case IXGBE_DEV_ID_X550EM_A_SGMII:
2408 case IXGBE_DEV_ID_X550EM_A_SGMII_L:
2409 case IXGBE_DEV_ID_X550EM_A_10G_T:
2410 case IXGBE_DEV_ID_X550EM_A_SFP:
2411 case IXGBE_DEV_ID_X550EM_A_QSFP:
2412 /* Config MDIO clock speed before the first MDIO PHY access */
2413 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
2414 hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
2415 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
2417 case IXGBE_DEV_ID_X550EM_A_1G_T:
2418 case IXGBE_DEV_ID_X550EM_A_1G_T_L:
2419 /* Select fast MDIO clock speed for these devices */
2420 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
2421 hlreg0 |= IXGBE_HLREG0_MDCSPD;
2422 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
2430 * ixgbe_reset_hw_X550em - Perform hardware reset
2431 * @hw: pointer to hardware structure
2433 * Resets the hardware by resetting the transmit and receive units, masks
2434 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
2437 s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
2439 ixgbe_link_speed link_speed;
2443 bool link_up = false;
2444 u32 swfw_mask = hw->phy.phy_semaphore_mask;
2446 DEBUGFUNC("ixgbe_reset_hw_X550em");
2448 /* Call adapter stop to disable Tx/Rx and clear interrupts */
2449 status = hw->mac.ops.stop_adapter(hw);
2450 if (status != IXGBE_SUCCESS) {
2451 DEBUGOUT1("Failed to stop adapter, STATUS = %d\n", status);
2454 /* flush pending Tx transactions */
2455 ixgbe_clear_tx_pending(hw);
2457 ixgbe_set_mdio_speed(hw);
2459 /* PHY ops must be identified and initialized prior to reset */
2460 status = hw->phy.ops.init(hw);
2463 DEBUGOUT1("Failed to initialize PHY ops, STATUS = %d\n",
2466 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED ||
2467 status == IXGBE_ERR_PHY_ADDR_INVALID) {
2468 DEBUGOUT("Returning from reset HW due to PHY init failure\n");
2472 /* start the external PHY */
2473 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
2474 status = ixgbe_init_ext_t_x550em(hw);
2476 DEBUGOUT1("Failed to start the external PHY, STATUS = %d\n",
2482 /* Setup SFP module if there is one present. */
2483 if (hw->phy.sfp_setup_needed) {
2484 status = hw->mac.ops.setup_sfp(hw);
2485 hw->phy.sfp_setup_needed = false;
2488 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
2492 if (!hw->phy.reset_disable && hw->phy.ops.reset) {
2493 if (hw->phy.ops.reset(hw) == IXGBE_ERR_OVERTEMP)
2494 return IXGBE_ERR_OVERTEMP;
2498 /* Issue global reset to the MAC. Needs to be SW reset if link is up.
2499 * If link reset is used when link is up, it might reset the PHY when
2500 * mng is using it. If link is down or the flag to force full link
2501 * reset is set, then perform link reset.
2503 ctrl = IXGBE_CTRL_LNK_RST;
2504 if (!hw->force_full_reset) {
2505 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
2507 ctrl = IXGBE_CTRL_RST;
2510 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
2511 if (status != IXGBE_SUCCESS) {
2512 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
2513 "semaphore failed with %d", status);
2514 return IXGBE_ERR_SWFW_SYNC;
2516 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
2517 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
2518 IXGBE_WRITE_FLUSH(hw);
2519 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
2521 /* Poll for reset bit to self-clear meaning reset is complete */
2522 for (i = 0; i < 10; i++) {
2524 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
2525 if (!(ctrl & IXGBE_CTRL_RST_MASK))
2529 if (ctrl & IXGBE_CTRL_RST_MASK) {
2530 status = IXGBE_ERR_RESET_FAILED;
2531 DEBUGOUT("Reset polling failed to complete.\n");
2536 /* Double resets are required for recovery from certain error
2537 * conditions. Between resets, it is necessary to stall to
2538 * allow time for any pending HW events to complete.
2540 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
2541 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
2545 /* Store the permanent mac address */
2546 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
2548 /* Store MAC address from RAR0, clear receive address registers, and
2549 * clear the multicast table. Also reset num_rar_entries to 128,
2550 * since we modify this value when programming the SAN MAC address.
2552 hw->mac.num_rar_entries = 128;
2553 hw->mac.ops.init_rx_addrs(hw);
2555 ixgbe_set_mdio_speed(hw);
2557 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
2558 ixgbe_setup_mux_ctl(hw);
2560 if (status != IXGBE_SUCCESS)
2561 DEBUGOUT1("Reset HW failed, STATUS = %d\n", status);
2567 * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
2568 * @hw: pointer to hardware structure
2570 s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
2575 status = hw->phy.ops.read_reg(hw,
2576 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
2577 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
2580 if (status != IXGBE_SUCCESS)
2583 /* If PHY FW reset completed bit is set then this is the first
2584 * SW instance after a power on so the PHY FW must be un-stalled.
2586 if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
2587 status = hw->phy.ops.read_reg(hw,
2588 IXGBE_MDIO_GLOBAL_RES_PR_10,
2589 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2592 if (status != IXGBE_SUCCESS)
2595 reg &= ~IXGBE_MDIO_POWER_UP_STALL;
2597 status = hw->phy.ops.write_reg(hw,
2598 IXGBE_MDIO_GLOBAL_RES_PR_10,
2599 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
2602 if (status != IXGBE_SUCCESS)
2610 * ixgbe_setup_kr_x550em - Configure the KR PHY.
2611 * @hw: pointer to hardware structure
2613 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
2615 /* leave link alone for 2.5G */
2616 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_2_5GB_FULL)
2617 return IXGBE_SUCCESS;
2619 if (ixgbe_check_reset_blocked(hw))
2622 return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
2626 * ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
2627 * @hw: pointer to hardware structure
2629 * Configure the external PHY and the integrated KR PHY for SFP support.
2631 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
2632 ixgbe_link_speed speed,
2633 bool autoneg_wait_to_complete)
2636 u16 reg_slice, reg_val;
2637 bool setup_linear = false;
2638 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
2640 /* Check if SFP module is supported and linear */
2641 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
2643 /* If no SFP module present, then return success. Return success since
2644 * there is no reason to configure CS4227 and SFP not present error is
2645 * not excepted in the setup MAC link flow.
2647 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
2648 return IXGBE_SUCCESS;
2650 if (ret_val != IXGBE_SUCCESS)
2653 /* Configure internal PHY for KR/KX. */
2654 ixgbe_setup_kr_speed_x550em(hw, speed);
2656 /* Configure CS4227 LINE side to proper mode. */
2657 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB +
2658 (hw->bus.lan_id << 12);
2660 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2662 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2663 ret_val = hw->link.ops.write_link(hw, hw->link.addr, reg_slice,
2669 * ixgbe_setup_sfi_x550a - Configure the internal PHY for native SFI mode
2670 * @hw: pointer to hardware structure
2671 * @speed: the link speed to force
2673 * Configures the integrated PHY for native SFI mode. Used to connect the
2674 * internal PHY directly to an SFP cage, without autonegotiation.
2676 STATIC s32 ixgbe_setup_sfi_x550a(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
2678 struct ixgbe_mac_info *mac = &hw->mac;
2682 /* Disable all AN and force speed to 10G Serial. */
2683 status = mac->ops.read_iosf_sb_reg(hw,
2684 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2685 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2686 if (status != IXGBE_SUCCESS)
2689 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN_EN;
2690 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_AN37_EN;
2691 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SGMII_EN;
2692 reg_val &= ~IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_MASK;
2694 /* Select forced link speed for internal PHY. */
2696 case IXGBE_LINK_SPEED_10GB_FULL:
2697 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_10G;
2699 case IXGBE_LINK_SPEED_1GB_FULL:
2700 reg_val |= IXGBE_KRM_PMD_FLX_MASK_ST20_SPEED_1G;
2703 /* Other link speeds are not supported by internal PHY. */
2704 return IXGBE_ERR_LINK_SETUP;
2707 status = mac->ops.write_iosf_sb_reg(hw,
2708 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2709 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2711 /* Toggle port SW reset by AN reset. */
2712 status = ixgbe_restart_an_internal_phy_x550em(hw);
2718 * ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
2719 * @hw: pointer to hardware structure
2721 * Configure the integrated PHY for SFP support.
2723 s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
2724 ixgbe_link_speed speed,
2725 bool autoneg_wait_to_complete)
2729 bool setup_linear = false;
2730 u32 reg_slice, reg_phy_int, slice_offset;
2732 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
2734 /* Check if SFP module is supported and linear */
2735 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
2737 /* If no SFP module present, then return success. Return success since
2738 * SFP not present error is not excepted in the setup MAC link flow.
2740 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
2741 return IXGBE_SUCCESS;
2743 if (ret_val != IXGBE_SUCCESS)
2746 if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) {
2747 /* Configure internal PHY for native SFI based on module type */
2748 ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
2749 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2750 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_phy_int);
2752 if (ret_val != IXGBE_SUCCESS)
2755 reg_phy_int &= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_DA;
2757 reg_phy_int |= IXGBE_KRM_PMD_FLX_MASK_ST20_SFI_10G_SR;
2759 ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
2760 IXGBE_KRM_PMD_FLX_MASK_ST20(hw->bus.lan_id),
2761 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_phy_int);
2763 if (ret_val != IXGBE_SUCCESS)
2766 /* Setup SFI internal link. */
2767 ret_val = ixgbe_setup_sfi_x550a(hw, &speed);
2769 /* Configure internal PHY for KR/KX. */
2770 ixgbe_setup_kr_speed_x550em(hw, speed);
2772 if (hw->phy.addr == 0x0 || hw->phy.addr == 0xFFFF) {
2774 DEBUGOUT("Invalid NW_MNG_IF_SEL.MDIO_PHY_ADD value\n");
2775 return IXGBE_ERR_PHY_ADDR_INVALID;
2778 /* Get external PHY SKU id */
2779 ret_val = hw->phy.ops.read_reg(hw, IXGBE_CS4227_EFUSE_PDF_SKU,
2780 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2782 if (ret_val != IXGBE_SUCCESS)
2785 /* When configuring quad port CS4223, the MAC instance is part
2786 * of the slice offset.
2788 if (reg_phy_ext == IXGBE_CS4223_SKU_ID)
2789 slice_offset = (hw->bus.lan_id +
2790 (hw->bus.instance_id << 1)) << 12;
2792 slice_offset = hw->bus.lan_id << 12;
2794 /* Configure CS4227/CS4223 LINE side to proper mode. */
2795 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + slice_offset;
2797 ret_val = hw->phy.ops.read_reg(hw, reg_slice,
2798 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2800 if (ret_val != IXGBE_SUCCESS)
2803 reg_phy_ext &= ~((IXGBE_CS4227_EDC_MODE_CX1 << 1) |
2804 (IXGBE_CS4227_EDC_MODE_SR << 1));
2807 reg_phy_ext = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
2809 reg_phy_ext = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
2810 ret_val = hw->phy.ops.write_reg(hw, reg_slice,
2811 IXGBE_MDIO_ZERO_DEV_TYPE, reg_phy_ext);
2813 /* Flush previous write with a read */
2814 ret_val = hw->phy.ops.read_reg(hw, reg_slice,
2815 IXGBE_MDIO_ZERO_DEV_TYPE, ®_phy_ext);
2821 * ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
2822 * @hw: pointer to hardware structure
2824 * iXfI configuration needed for ixgbe_mac_X550EM_x devices.
2826 STATIC s32 ixgbe_setup_ixfi_x550em_x(struct ixgbe_hw *hw)
2828 struct ixgbe_mac_info *mac = &hw->mac;
2832 /* Disable training protocol FSM. */
2833 status = mac->ops.read_iosf_sb_reg(hw,
2834 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2835 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2836 if (status != IXGBE_SUCCESS)
2838 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
2839 status = mac->ops.write_iosf_sb_reg(hw,
2840 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2841 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2842 if (status != IXGBE_SUCCESS)
2845 /* Disable Flex from training TXFFE. */
2846 status = mac->ops.read_iosf_sb_reg(hw,
2847 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
2848 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2849 if (status != IXGBE_SUCCESS)
2851 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
2852 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
2853 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
2854 status = mac->ops.write_iosf_sb_reg(hw,
2855 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
2856 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2857 if (status != IXGBE_SUCCESS)
2859 status = mac->ops.read_iosf_sb_reg(hw,
2860 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
2861 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2862 if (status != IXGBE_SUCCESS)
2864 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
2865 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
2866 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
2867 status = mac->ops.write_iosf_sb_reg(hw,
2868 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
2869 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2870 if (status != IXGBE_SUCCESS)
2873 /* Enable override for coefficients. */
2874 status = mac->ops.read_iosf_sb_reg(hw,
2875 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2876 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2877 if (status != IXGBE_SUCCESS)
2879 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
2880 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
2881 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
2882 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
2883 status = mac->ops.write_iosf_sb_reg(hw,
2884 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
2885 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2890 * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
2891 * @hw: pointer to hardware structure
2892 * @speed: the link speed to force
2894 * Configures the integrated KR PHY to use iXFI mode. Used to connect an
2895 * internal and external PHY at a specific speed, without autonegotiation.
2897 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
2899 struct ixgbe_mac_info *mac = &hw->mac;
2903 /* iXFI is only supported with X552 */
2904 if (mac->type != ixgbe_mac_X550EM_x)
2905 return IXGBE_ERR_LINK_SETUP;
2907 /* Disable AN and force speed to 10G Serial. */
2908 status = mac->ops.read_iosf_sb_reg(hw,
2909 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2910 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2911 if (status != IXGBE_SUCCESS)
2914 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2915 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2917 /* Select forced link speed for internal PHY. */
2919 case IXGBE_LINK_SPEED_10GB_FULL:
2920 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2922 case IXGBE_LINK_SPEED_1GB_FULL:
2923 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
2926 /* Other link speeds are not supported by internal KR PHY. */
2927 return IXGBE_ERR_LINK_SETUP;
2930 status = mac->ops.write_iosf_sb_reg(hw,
2931 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2932 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2933 if (status != IXGBE_SUCCESS)
2936 /* Additional configuration needed for x550em_x */
2937 if (hw->mac.type == ixgbe_mac_X550EM_x) {
2938 status = ixgbe_setup_ixfi_x550em_x(hw);
2939 if (status != IXGBE_SUCCESS)
2943 /* Toggle port SW reset by AN reset. */
2944 status = ixgbe_restart_an_internal_phy_x550em(hw);
2950 * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
2951 * @hw: address of hardware structure
2952 * @link_up: address of boolean to indicate link status
2954 * Returns error code if unable to get link status.
2956 STATIC s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
2963 /* read this twice back to back to indicate current status */
2964 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
2965 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2967 if (ret != IXGBE_SUCCESS)
2970 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
2971 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2973 if (ret != IXGBE_SUCCESS)
2976 *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
2978 return IXGBE_SUCCESS;
2982 * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
2983 * @hw: point to hardware structure
2985 * Configures the link between the integrated KR PHY and the external X557 PHY
2986 * The driver will call this function when it gets a link status change
2987 * interrupt from the X557 PHY. This function configures the link speed
2988 * between the PHYs to match the link speed of the BASE-T link.
2990 * A return of a non-zero value indicates an error, and the base driver should
2991 * not report link up.
2993 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
2995 ixgbe_link_speed force_speed;
3000 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
3001 return IXGBE_ERR_CONFIG;
3003 if (hw->mac.type == ixgbe_mac_X550EM_x &&
3004 !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
3005 /* If link is down, there is no setup necessary so return */
3006 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3007 if (status != IXGBE_SUCCESS)
3011 return IXGBE_SUCCESS;
3013 status = hw->phy.ops.read_reg(hw,
3014 IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
3015 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3017 if (status != IXGBE_SUCCESS)
3020 /* If link is still down - no setup is required so return */
3021 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3022 if (status != IXGBE_SUCCESS)
3025 return IXGBE_SUCCESS;
3027 /* clear everything but the speed and duplex bits */
3028 speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
3031 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
3032 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
3034 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
3035 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
3038 /* Internal PHY does not support anything else */
3039 return IXGBE_ERR_INVALID_LINK_SETTINGS;
3042 return ixgbe_setup_ixfi_x550em(hw, &force_speed);
3044 speed = IXGBE_LINK_SPEED_10GB_FULL |
3045 IXGBE_LINK_SPEED_1GB_FULL;
3046 return ixgbe_setup_kr_speed_x550em(hw, speed);
3051 * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
3052 * @hw: pointer to hardware structure
3054 * Configures the integrated KR PHY to use internal loopback mode.
3056 s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
3061 /* Disable AN and force speed to 10G Serial. */
3062 status = hw->mac.ops.read_iosf_sb_reg(hw,
3063 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
3064 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3065 if (status != IXGBE_SUCCESS)
3067 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
3068 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
3069 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
3070 status = hw->mac.ops.write_iosf_sb_reg(hw,
3071 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
3072 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3073 if (status != IXGBE_SUCCESS)
3076 /* Set near-end loopback clocks. */
3077 status = hw->mac.ops.read_iosf_sb_reg(hw,
3078 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
3079 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3080 if (status != IXGBE_SUCCESS)
3082 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
3083 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
3084 status = hw->mac.ops.write_iosf_sb_reg(hw,
3085 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
3086 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3087 if (status != IXGBE_SUCCESS)
3090 /* Set loopback enable. */
3091 status = hw->mac.ops.read_iosf_sb_reg(hw,
3092 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
3093 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3094 if (status != IXGBE_SUCCESS)
3096 reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
3097 status = hw->mac.ops.write_iosf_sb_reg(hw,
3098 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
3099 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3100 if (status != IXGBE_SUCCESS)
3103 /* Training bypass. */
3104 status = hw->mac.ops.read_iosf_sb_reg(hw,
3105 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
3106 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3107 if (status != IXGBE_SUCCESS)
3109 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
3110 status = hw->mac.ops.write_iosf_sb_reg(hw,
3111 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
3112 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3118 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
3119 * assuming that the semaphore is already obtained.
3120 * @hw: pointer to hardware structure
3121 * @offset: offset of word in the EEPROM to read
3122 * @data: word read from the EEPROM
3124 * Reads a 16 bit word from the EEPROM using the hostif.
3126 s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 *data)
3128 const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
3129 struct ixgbe_hic_read_shadow_ram buffer;
3132 DEBUGFUNC("ixgbe_read_ee_hostif_X550");
3133 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
3134 buffer.hdr.req.buf_lenh = 0;
3135 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
3136 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3138 /* convert offset from words to bytes */
3139 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
3141 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
3145 status = hw->mac.ops.acquire_swfw_sync(hw, mask);
3149 status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
3150 IXGBE_HI_COMMAND_TIMEOUT);
3152 *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
3153 FW_NVM_DATA_OFFSET);
3156 hw->mac.ops.release_swfw_sync(hw, mask);
3161 * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
3162 * @hw: pointer to hardware structure
3163 * @offset: offset of word in the EEPROM to read
3164 * @words: number of words
3165 * @data: word(s) read from the EEPROM
3167 * Reads a 16 bit word(s) from the EEPROM using the hostif.
3169 s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
3170 u16 offset, u16 words, u16 *data)
3172 const u32 mask = IXGBE_GSSR_SW_MNG_SM | IXGBE_GSSR_EEP_SM;
3173 struct ixgbe_hic_read_shadow_ram buffer;
3174 u32 current_word = 0;
3179 DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
3181 /* Take semaphore for the entire operation. */
3182 status = hw->mac.ops.acquire_swfw_sync(hw, mask);
3184 DEBUGOUT("EEPROM read buffer - semaphore failed\n");
3189 if (words > FW_MAX_READ_BUFFER_SIZE / 2)
3190 words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
3192 words_to_read = words;
3194 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
3195 buffer.hdr.req.buf_lenh = 0;
3196 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
3197 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3199 /* convert offset from words to bytes */
3200 buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
3201 buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
3205 status = ixgbe_hic_unlocked(hw, (u32 *)&buffer, sizeof(buffer),
3206 IXGBE_HI_COMMAND_TIMEOUT);
3209 DEBUGOUT("Host interface command failed\n");
3213 for (i = 0; i < words_to_read; i++) {
3214 u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
3216 u32 value = IXGBE_READ_REG(hw, reg);
3218 data[current_word] = (u16)(value & 0xffff);
3221 if (i < words_to_read) {
3223 data[current_word] = (u16)(value & 0xffff);
3227 words -= words_to_read;
3231 hw->mac.ops.release_swfw_sync(hw, mask);
3236 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
3237 * @hw: pointer to hardware structure
3238 * @offset: offset of word in the EEPROM to write
3239 * @data: word write to the EEPROM
3241 * Write a 16 bit word to the EEPROM using the hostif.
3243 s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
3247 struct ixgbe_hic_write_shadow_ram buffer;
3249 DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
3251 buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
3252 buffer.hdr.req.buf_lenh = 0;
3253 buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
3254 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
3257 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
3259 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
3261 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
3263 IXGBE_HI_COMMAND_TIMEOUT, false);
3269 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
3270 * @hw: pointer to hardware structure
3271 * @offset: offset of word in the EEPROM to write
3272 * @data: word write to the EEPROM
3274 * Write a 16 bit word to the EEPROM using the hostif.
3276 s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
3279 s32 status = IXGBE_SUCCESS;
3281 DEBUGFUNC("ixgbe_write_ee_hostif_X550");
3283 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
3285 status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
3286 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3288 DEBUGOUT("write ee hostif failed to get semaphore");
3289 status = IXGBE_ERR_SWFW_SYNC;
3296 * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
3297 * @hw: pointer to hardware structure
3298 * @offset: offset of word in the EEPROM to write
3299 * @words: number of words
3300 * @data: word(s) write to the EEPROM
3302 * Write a 16 bit word(s) to the EEPROM using the hostif.
3304 s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
3305 u16 offset, u16 words, u16 *data)
3307 s32 status = IXGBE_SUCCESS;
3310 DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
3312 /* Take semaphore for the entire operation. */
3313 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3314 if (status != IXGBE_SUCCESS) {
3315 DEBUGOUT("EEPROM write buffer - semaphore failed\n");
3319 for (i = 0; i < words; i++) {
3320 status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
3323 if (status != IXGBE_SUCCESS) {
3324 DEBUGOUT("Eeprom buffered write failed\n");
3329 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
3336 * ixgbe_checksum_ptr_x550 - Checksum one pointer region
3337 * @hw: pointer to hardware structure
3338 * @ptr: pointer offset in eeprom
3339 * @size: size of section pointed by ptr, if 0 first word will be used as size
3340 * @csum: address of checksum to update
3342 * Returns error status for any failure
3344 STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
3345 u16 size, u16 *csum, u16 *buffer,
3350 u16 length, bufsz, i, start;
3353 bufsz = sizeof(buf) / sizeof(buf[0]);
3355 /* Read a chunk at the pointer location */
3357 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
3359 DEBUGOUT("Failed to read EEPROM image\n");
3364 if (buffer_size < ptr)
3365 return IXGBE_ERR_PARAM;
3366 local_buffer = &buffer[ptr];
3374 length = local_buffer[0];
3376 /* Skip pointer section if length is invalid. */
3377 if (length == 0xFFFF || length == 0 ||
3378 (ptr + length) >= hw->eeprom.word_size)
3379 return IXGBE_SUCCESS;
3382 if (buffer && ((u32)start + (u32)length > buffer_size))
3383 return IXGBE_ERR_PARAM;
3385 for (i = start; length; i++, length--) {
3386 if (i == bufsz && !buffer) {
3392 /* Read a chunk at the pointer location */
3393 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
3396 DEBUGOUT("Failed to read EEPROM image\n");
3400 *csum += local_buffer[i];
3402 return IXGBE_SUCCESS;
3406 * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
3407 * @hw: pointer to hardware structure
3408 * @buffer: pointer to buffer containing calculated checksum
3409 * @buffer_size: size of buffer
3411 * Returns a negative error code on error, or the 16-bit checksum
3413 s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
3415 u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
3419 u16 pointer, i, size;
3421 DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
3423 hw->eeprom.ops.init_params(hw);
3426 /* Read pointer area */
3427 status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
3428 IXGBE_EEPROM_LAST_WORD + 1,
3431 DEBUGOUT("Failed to read EEPROM image\n");
3434 local_buffer = eeprom_ptrs;
3436 if (buffer_size < IXGBE_EEPROM_LAST_WORD)
3437 return IXGBE_ERR_PARAM;
3438 local_buffer = buffer;
3442 * For X550 hardware include 0x0-0x41 in the checksum, skip the
3443 * checksum word itself
3445 for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
3446 if (i != IXGBE_EEPROM_CHECKSUM)
3447 checksum += local_buffer[i];
3450 * Include all data from pointers 0x3, 0x6-0xE. This excludes the
3451 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
3453 for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
3454 if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
3457 pointer = local_buffer[i];
3459 /* Skip pointer section if the pointer is invalid. */
3460 if (pointer == 0xFFFF || pointer == 0 ||
3461 pointer >= hw->eeprom.word_size)
3465 case IXGBE_PCIE_GENERAL_PTR:
3466 size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
3468 case IXGBE_PCIE_CONFIG0_PTR:
3469 case IXGBE_PCIE_CONFIG1_PTR:
3470 size = IXGBE_PCIE_CONFIG_SIZE;
3477 status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
3478 buffer, buffer_size);
3483 checksum = (u16)IXGBE_EEPROM_SUM - checksum;
3485 return (s32)checksum;
3489 * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
3490 * @hw: pointer to hardware structure
3492 * Returns a negative error code on error, or the 16-bit checksum
3494 s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
3496 return ixgbe_calc_checksum_X550(hw, NULL, 0);
3500 * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
3501 * @hw: pointer to hardware structure
3502 * @checksum_val: calculated checksum
3504 * Performs checksum calculation and validates the EEPROM checksum. If the
3505 * caller does not need checksum_val, the value can be NULL.
3507 s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
3511 u16 read_checksum = 0;
3513 DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
3515 /* Read the first word from the EEPROM. If this times out or fails, do
3516 * not continue or we could be in for a very long wait while every
3519 status = hw->eeprom.ops.read(hw, 0, &checksum);
3521 DEBUGOUT("EEPROM read failed\n");
3525 status = hw->eeprom.ops.calc_checksum(hw);
3529 checksum = (u16)(status & 0xffff);
3531 status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
3536 /* Verify read checksum from EEPROM is the same as
3537 * calculated checksum
3539 if (read_checksum != checksum) {
3540 status = IXGBE_ERR_EEPROM_CHECKSUM;
3541 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
3542 "Invalid EEPROM checksum");
3545 /* If the user cares, return the calculated checksum */
3547 *checksum_val = checksum;
3553 * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
3554 * @hw: pointer to hardware structure
3556 * After writing EEPROM to shadow RAM using EEWR register, software calculates
3557 * checksum and updates the EEPROM and instructs the hardware to update
3560 s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
3565 DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
3567 /* Read the first word from the EEPROM. If this times out or fails, do
3568 * not continue or we could be in for a very long wait while every
3571 status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
3573 DEBUGOUT("EEPROM read failed\n");
3577 status = ixgbe_calc_eeprom_checksum_X550(hw);
3581 checksum = (u16)(status & 0xffff);
3583 status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
3588 status = ixgbe_update_flash_X550(hw);
3594 * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
3595 * @hw: pointer to hardware structure
3597 * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
3599 s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
3601 s32 status = IXGBE_SUCCESS;
3602 union ixgbe_hic_hdr2 buffer;
3604 DEBUGFUNC("ixgbe_update_flash_X550");
3606 buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
3607 buffer.req.buf_lenh = 0;
3608 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
3609 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
3611 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
3613 IXGBE_HI_COMMAND_TIMEOUT, false);
3619 * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
3620 * @hw: pointer to hardware structure
3622 * Determines physical layer capabilities of the current configuration.
3624 u64 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
3626 u64 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
3627 u16 ext_ability = 0;
3629 DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
3631 hw->phy.ops.identify(hw);
3633 switch (hw->phy.type) {
3634 case ixgbe_phy_x550em_kr:
3635 if (hw->mac.type == ixgbe_mac_X550EM_a) {
3636 if (hw->phy.nw_mng_if_sel &
3637 IXGBE_NW_MNG_IF_SEL_PHY_SPEED_2_5G) {
3639 IXGBE_PHYSICAL_LAYER_2500BASE_KX;
3641 } else if (hw->device_id ==
3642 IXGBE_DEV_ID_X550EM_A_KR_L) {
3644 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3649 case ixgbe_phy_x550em_xfi:
3650 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
3651 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3653 case ixgbe_phy_x550em_kx4:
3654 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
3655 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3657 case ixgbe_phy_x550em_ext_t:
3658 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
3659 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
3661 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
3662 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
3663 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
3664 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3667 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_1GB_FULL)
3668 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3669 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_100_FULL)
3670 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
3671 if (hw->phy.speeds_supported & IXGBE_LINK_SPEED_10_FULL)
3672 physical_layer |= IXGBE_PHYSICAL_LAYER_10BASE_T;
3674 case ixgbe_phy_sgmii:
3675 #ifdef PREBOOT_SUPPORT
3676 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX |
3677 IXGBE_PHYSICAL_LAYER_100BASE_TX |
3678 IXGBE_PHYSICAL_LAYER_10BASE_T;
3680 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX;
3681 #endif /* PREBOOT_SUPPORT */
3683 case ixgbe_phy_ext_1g_t:
3684 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
3690 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
3691 physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
3693 return physical_layer;
3697 * ixgbe_get_bus_info_x550em - Set PCI bus info
3698 * @hw: pointer to hardware structure
3700 * Sets bus link width and speed to unknown because X550em is
3703 s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
3706 DEBUGFUNC("ixgbe_get_bus_info_x550em");
3708 hw->bus.width = ixgbe_bus_width_unknown;
3709 hw->bus.speed = ixgbe_bus_speed_unknown;
3711 hw->mac.ops.set_lan_id(hw);
3713 return IXGBE_SUCCESS;
3717 * ixgbe_disable_rx_x550 - Disable RX unit
3719 * Enables the Rx DMA unit for x550
3721 void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
3723 u32 rxctrl, pfdtxgswc;
3725 struct ixgbe_hic_disable_rxen fw_cmd;
3727 DEBUGFUNC("ixgbe_enable_rx_dma_x550");
3729 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
3730 if (rxctrl & IXGBE_RXCTRL_RXEN) {
3731 pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
3732 if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
3733 pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
3734 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
3735 hw->mac.set_lben = true;
3737 hw->mac.set_lben = false;
3740 fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
3741 fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
3742 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
3743 fw_cmd.port_number = (u8)hw->bus.lan_id;
3745 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
3746 sizeof(struct ixgbe_hic_disable_rxen),
3747 IXGBE_HI_COMMAND_TIMEOUT, true);
3749 /* If we fail - disable RX using register write */
3751 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
3752 if (rxctrl & IXGBE_RXCTRL_RXEN) {
3753 rxctrl &= ~IXGBE_RXCTRL_RXEN;
3754 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
3761 * ixgbe_enter_lplu_x550em - Transition to low power states
3762 * @hw: pointer to hardware structure
3764 * Configures Low Power Link Up on transition to low power states
3765 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
3766 * X557 PHY immediately prior to entering LPLU.
3768 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
3770 u16 an_10g_cntl_reg, autoneg_reg, speed;
3772 ixgbe_link_speed lcd_speed;
3776 /* SW LPLU not required on later HW revisions. */
3777 if ((hw->mac.type == ixgbe_mac_X550EM_x) &&
3778 (IXGBE_FUSES0_REV_MASK &
3779 IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0))))
3780 return IXGBE_SUCCESS;
3782 /* If blocked by MNG FW, then don't restart AN */
3783 if (ixgbe_check_reset_blocked(hw))
3784 return IXGBE_SUCCESS;
3786 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3787 if (status != IXGBE_SUCCESS)
3790 status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
3792 if (status != IXGBE_SUCCESS)
3795 /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
3796 * disabled, then force link down by entering low power mode.
3798 if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
3799 !(hw->wol_enabled || ixgbe_mng_present(hw)))
3800 return ixgbe_set_copper_phy_power(hw, FALSE);
3803 status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
3805 if (status != IXGBE_SUCCESS)
3808 /* If no valid LCD link speed, then force link down and exit. */
3809 if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
3810 return ixgbe_set_copper_phy_power(hw, FALSE);
3812 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
3813 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3816 if (status != IXGBE_SUCCESS)
3819 /* If no link now, speed is invalid so take link down */
3820 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
3821 if (status != IXGBE_SUCCESS)
3822 return ixgbe_set_copper_phy_power(hw, false);
3824 /* clear everything but the speed bits */
3825 speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
3827 /* If current speed is already LCD, then exit. */
3828 if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
3829 (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
3830 ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
3831 (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
3834 /* Clear AN completed indication */
3835 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
3836 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3839 if (status != IXGBE_SUCCESS)
3842 status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
3843 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3846 if (status != IXGBE_SUCCESS)
3849 status = hw->phy.ops.read_reg(hw,
3850 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
3851 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3854 if (status != IXGBE_SUCCESS)
3857 save_autoneg = hw->phy.autoneg_advertised;
3859 /* Setup link at least common link speed */
3860 status = hw->mac.ops.setup_link(hw, lcd_speed, false);
3862 /* restore autoneg from before setting lplu speed */
3863 hw->phy.autoneg_advertised = save_autoneg;
3869 * ixgbe_get_lcd_x550em - Determine lowest common denominator
3870 * @hw: pointer to hardware structure
3871 * @lcd_speed: pointer to lowest common link speed
3873 * Determine lowest common link speed with link partner.
3875 s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
3879 u16 word = hw->eeprom.ctrl_word_3;
3881 *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
3883 status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
3884 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3887 if (status != IXGBE_SUCCESS)
3890 /* If link partner advertised 1G, return 1G */
3891 if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
3892 *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
3896 /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
3897 if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
3898 (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
3901 /* Link partner not capable of lower speeds, return 10G */
3902 *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
3907 * ixgbe_setup_fc_X550em - Set up flow control
3908 * @hw: pointer to hardware structure
3910 * Called at init time to set up flow control.
3912 s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
3914 s32 ret_val = IXGBE_SUCCESS;
3915 u32 pause, asm_dir, reg_val;
3917 DEBUGFUNC("ixgbe_setup_fc_X550em");
3919 /* Validate the requested mode */
3920 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
3921 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
3922 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
3923 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
3927 /* 10gig parts do not have a word in the EEPROM to determine the
3928 * default flow control setting, so we explicitly set it to full.
3930 if (hw->fc.requested_mode == ixgbe_fc_default)
3931 hw->fc.requested_mode = ixgbe_fc_full;
3933 /* Determine PAUSE and ASM_DIR bits. */
3934 switch (hw->fc.requested_mode) {
3939 case ixgbe_fc_tx_pause:
3943 case ixgbe_fc_rx_pause:
3944 /* Rx Flow control is enabled and Tx Flow control is
3945 * disabled by software override. Since there really
3946 * isn't a way to advertise that we are capable of RX
3947 * Pause ONLY, we will advertise that we support both
3948 * symmetric and asymmetric Rx PAUSE, as such we fall
3949 * through to the fc_full statement. Later, we will
3950 * disable the adapter's ability to send PAUSE frames.
3957 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
3958 "Flow control param set incorrectly\n");
3959 ret_val = IXGBE_ERR_CONFIG;
3963 switch (hw->device_id) {
3964 case IXGBE_DEV_ID_X550EM_X_KR:
3965 case IXGBE_DEV_ID_X550EM_A_KR:
3966 case IXGBE_DEV_ID_X550EM_A_KR_L:
3967 ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
3968 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
3969 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
3970 if (ret_val != IXGBE_SUCCESS)
3972 reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
3973 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
3975 reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
3977 reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
3978 ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
3979 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
3980 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
3982 /* This device does not fully support AN. */
3983 hw->fc.disable_fc_autoneg = true;
3985 case IXGBE_DEV_ID_X550EM_X_XFI:
3986 hw->fc.disable_fc_autoneg = true;
3997 * ixgbe_fc_autoneg_backplane_x550em_a - Enable flow control IEEE clause 37
3998 * @hw: pointer to hardware structure
4000 * Enable flow control according to IEEE clause 37.
4002 void ixgbe_fc_autoneg_backplane_x550em_a(struct ixgbe_hw *hw)
4004 u32 link_s1, lp_an_page_low, an_cntl_1;
4005 s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4006 ixgbe_link_speed speed;
4009 /* AN should have completed when the cable was plugged in.
4010 * Look for reasons to bail out. Bail out if:
4011 * - FC autoneg is disabled, or if
4014 if (hw->fc.disable_fc_autoneg) {
4015 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4016 "Flow control autoneg is disabled");
4020 hw->mac.ops.check_link(hw, &speed, &link_up, false);
4022 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
4026 /* Check at auto-negotiation has completed */
4027 status = hw->mac.ops.read_iosf_sb_reg(hw,
4028 IXGBE_KRM_LINK_S1(hw->bus.lan_id),
4029 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_s1);
4031 if (status != IXGBE_SUCCESS ||
4032 (link_s1 & IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE) == 0) {
4033 DEBUGOUT("Auto-Negotiation did not complete\n");
4034 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4038 /* Read the 10g AN autoc and LP ability registers and resolve
4039 * local flow control settings accordingly
4041 status = hw->mac.ops.read_iosf_sb_reg(hw,
4042 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4043 IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl_1);
4045 if (status != IXGBE_SUCCESS) {
4046 DEBUGOUT("Auto-Negotiation did not complete\n");
4050 status = hw->mac.ops.read_iosf_sb_reg(hw,
4051 IXGBE_KRM_LP_BASE_PAGE_HIGH(hw->bus.lan_id),
4052 IXGBE_SB_IOSF_TARGET_KR_PHY, &lp_an_page_low);
4054 if (status != IXGBE_SUCCESS) {
4055 DEBUGOUT("Auto-Negotiation did not complete\n");
4059 status = ixgbe_negotiate_fc(hw, an_cntl_1, lp_an_page_low,
4060 IXGBE_KRM_AN_CNTL_1_SYM_PAUSE,
4061 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE,
4062 IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE,
4063 IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE);
4066 if (status == IXGBE_SUCCESS) {
4067 hw->fc.fc_was_autonegged = true;
4069 hw->fc.fc_was_autonegged = false;
4070 hw->fc.current_mode = hw->fc.requested_mode;
4075 * ixgbe_fc_autoneg_fiber_x550em_a - passthrough FC settings
4076 * @hw: pointer to hardware structure
4079 void ixgbe_fc_autoneg_fiber_x550em_a(struct ixgbe_hw *hw)
4081 hw->fc.fc_was_autonegged = false;
4082 hw->fc.current_mode = hw->fc.requested_mode;
4086 * ixgbe_fc_autoneg_sgmii_x550em_a - Enable flow control IEEE clause 37
4087 * @hw: pointer to hardware structure
4089 * Enable flow control according to IEEE clause 37.
4091 void ixgbe_fc_autoneg_sgmii_x550em_a(struct ixgbe_hw *hw)
4093 s32 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4094 u32 info[FW_PHY_ACT_DATA_COUNT] = { 0 };
4095 ixgbe_link_speed speed;
4098 /* AN should have completed when the cable was plugged in.
4099 * Look for reasons to bail out. Bail out if:
4100 * - FC autoneg is disabled, or if
4103 if (hw->fc.disable_fc_autoneg) {
4104 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4105 "Flow control autoneg is disabled");
4109 hw->mac.ops.check_link(hw, &speed, &link_up, false);
4111 ERROR_REPORT1(IXGBE_ERROR_SOFTWARE, "The link is down");
4115 /* Check if auto-negotiation has completed */
4116 status = ixgbe_fw_phy_activity(hw, FW_PHY_ACT_GET_LINK_INFO, &info);
4117 if (status != IXGBE_SUCCESS ||
4118 !(info[0] & FW_PHY_ACT_GET_LINK_INFO_AN_COMPLETE)) {
4119 DEBUGOUT("Auto-Negotiation did not complete\n");
4120 status = IXGBE_ERR_FC_NOT_NEGOTIATED;
4124 /* Negotiate the flow control */
4125 status = ixgbe_negotiate_fc(hw, info[0], info[0],
4126 FW_PHY_ACT_GET_LINK_INFO_FC_RX,
4127 FW_PHY_ACT_GET_LINK_INFO_FC_TX,
4128 FW_PHY_ACT_GET_LINK_INFO_LP_FC_RX,
4129 FW_PHY_ACT_GET_LINK_INFO_LP_FC_TX);
4132 if (status == IXGBE_SUCCESS) {
4133 hw->fc.fc_was_autonegged = true;
4135 hw->fc.fc_was_autonegged = false;
4136 hw->fc.current_mode = hw->fc.requested_mode;
4141 * ixgbe_setup_fc_backplane_x550em_a - Set up flow control
4142 * @hw: pointer to hardware structure
4144 * Called at init time to set up flow control.
4146 s32 ixgbe_setup_fc_backplane_x550em_a(struct ixgbe_hw *hw)
4148 s32 status = IXGBE_SUCCESS;
4151 DEBUGFUNC("ixgbe_setup_fc_backplane_x550em_a");
4153 /* Validate the requested mode */
4154 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
4155 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
4156 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
4157 return IXGBE_ERR_INVALID_LINK_SETTINGS;
4160 if (hw->fc.requested_mode == ixgbe_fc_default)
4161 hw->fc.requested_mode = ixgbe_fc_full;
4163 /* Set up the 1G and 10G flow control advertisement registers so the
4164 * HW will be able to do FC autoneg once the cable is plugged in. If
4165 * we link at 10G, the 1G advertisement is harmless and vice versa.
4167 status = hw->mac.ops.read_iosf_sb_reg(hw,
4168 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4169 IXGBE_SB_IOSF_TARGET_KR_PHY, &an_cntl);
4171 if (status != IXGBE_SUCCESS) {
4172 DEBUGOUT("Auto-Negotiation did not complete\n");
4176 /* The possible values of fc.requested_mode are:
4177 * 0: Flow control is completely disabled
4178 * 1: Rx flow control is enabled (we can receive pause frames,
4179 * but not send pause frames).
4180 * 2: Tx flow control is enabled (we can send pause frames but
4181 * we do not support receiving pause frames).
4182 * 3: Both Rx and Tx flow control (symmetric) are enabled.
4185 switch (hw->fc.requested_mode) {
4187 /* Flow control completely disabled by software override. */
4188 an_cntl &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
4189 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
4191 case ixgbe_fc_tx_pause:
4192 /* Tx Flow control is enabled, and Rx Flow control is
4193 * disabled by software override.
4195 an_cntl |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
4196 an_cntl &= ~IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
4198 case ixgbe_fc_rx_pause:
4199 /* Rx Flow control is enabled and Tx Flow control is
4200 * disabled by software override. Since there really
4201 * isn't a way to advertise that we are capable of RX
4202 * Pause ONLY, we will advertise that we support both
4203 * symmetric and asymmetric Rx PAUSE, as such we fall
4204 * through to the fc_full statement. Later, we will
4205 * disable the adapter's ability to send PAUSE frames.
4208 /* Flow control (both Rx and Tx) is enabled by SW override. */
4209 an_cntl |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
4210 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
4213 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
4214 "Flow control param set incorrectly\n");
4215 return IXGBE_ERR_CONFIG;
4218 status = hw->mac.ops.write_iosf_sb_reg(hw,
4219 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
4220 IXGBE_SB_IOSF_TARGET_KR_PHY, an_cntl);
4222 /* Restart auto-negotiation. */
4223 status = ixgbe_restart_an_internal_phy_x550em(hw);
4229 * ixgbe_set_mux - Set mux for port 1 access with CS4227
4230 * @hw: pointer to hardware structure
4231 * @state: set mux if 1, clear if 0
4233 STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
4237 if (!hw->bus.lan_id)
4239 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
4241 esdp |= IXGBE_ESDP_SDP1;
4243 esdp &= ~IXGBE_ESDP_SDP1;
4244 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
4245 IXGBE_WRITE_FLUSH(hw);
4249 * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
4250 * @hw: pointer to hardware structure
4251 * @mask: Mask to specify which semaphore to acquire
4253 * Acquires the SWFW semaphore and sets the I2C MUX
4255 s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
4259 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
4261 status = ixgbe_acquire_swfw_sync_X540(hw, mask);
4265 if (mask & IXGBE_GSSR_I2C_MASK)
4266 ixgbe_set_mux(hw, 1);
4268 return IXGBE_SUCCESS;
4272 * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
4273 * @hw: pointer to hardware structure
4274 * @mask: Mask to specify which semaphore to release
4276 * Releases the SWFW semaphore and sets the I2C MUX
4278 void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
4280 DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
4282 if (mask & IXGBE_GSSR_I2C_MASK)
4283 ixgbe_set_mux(hw, 0);
4285 ixgbe_release_swfw_sync_X540(hw, mask);
4289 * ixgbe_acquire_swfw_sync_X550a - Acquire SWFW semaphore
4290 * @hw: pointer to hardware structure
4291 * @mask: Mask to specify which semaphore to acquire
4293 * Acquires the SWFW semaphore and get the shared phy token as needed
4295 STATIC s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
4297 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
4298 int retries = FW_PHY_TOKEN_RETRIES;
4299 s32 status = IXGBE_SUCCESS;
4301 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550a");
4304 status = IXGBE_SUCCESS;
4306 status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
4308 DEBUGOUT1("Could not acquire SWFW semaphore, Status = %d\n",
4312 if (!(mask & IXGBE_GSSR_TOKEN_SM))
4313 return IXGBE_SUCCESS;
4315 status = ixgbe_get_phy_token(hw);
4316 if (status == IXGBE_ERR_TOKEN_RETRY)
4317 DEBUGOUT1("Could not acquire PHY token, Status = %d\n",
4320 if (status == IXGBE_SUCCESS)
4321 return IXGBE_SUCCESS;
4324 ixgbe_release_swfw_sync_X540(hw, hmask);
4326 if (status != IXGBE_ERR_TOKEN_RETRY) {
4327 DEBUGOUT1("Unable to retry acquiring the PHY token, Status = %d\n",
4333 DEBUGOUT1("Semaphore acquisition retries failed!: PHY ID = 0x%08X\n",
4339 * ixgbe_release_swfw_sync_X550a - Release SWFW semaphore
4340 * @hw: pointer to hardware structure
4341 * @mask: Mask to specify which semaphore to release
4343 * Releases the SWFW semaphore and puts the shared phy token as needed
4345 STATIC void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *hw, u32 mask)
4347 u32 hmask = mask & ~IXGBE_GSSR_TOKEN_SM;
4349 DEBUGFUNC("ixgbe_release_swfw_sync_X550a");
4351 if (mask & IXGBE_GSSR_TOKEN_SM)
4352 ixgbe_put_phy_token(hw);
4355 ixgbe_release_swfw_sync_X540(hw, hmask);
4359 * ixgbe_read_phy_reg_x550a - Reads specified PHY register
4360 * @hw: pointer to hardware structure
4361 * @reg_addr: 32 bit address of PHY register to read
4362 * @phy_data: Pointer to read data from PHY register
4364 * Reads a value from a specified PHY register using the SWFW lock and PHY
4365 * Token. The PHY Token is needed since the MDIO is shared between to MAC
4368 s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
4369 u32 device_type, u16 *phy_data)
4372 u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
4374 DEBUGFUNC("ixgbe_read_phy_reg_x550a");
4376 if (hw->mac.ops.acquire_swfw_sync(hw, mask))
4377 return IXGBE_ERR_SWFW_SYNC;
4379 status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
4381 hw->mac.ops.release_swfw_sync(hw, mask);
4387 * ixgbe_write_phy_reg_x550a - Writes specified PHY register
4388 * @hw: pointer to hardware structure
4389 * @reg_addr: 32 bit PHY register to write
4390 * @device_type: 5 bit device type
4391 * @phy_data: Data to write to the PHY register
4393 * Writes a value to specified PHY register using the SWFW lock and PHY Token.
4394 * The PHY Token is needed since the MDIO is shared between to MAC instances.
4396 s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
4397 u32 device_type, u16 phy_data)
4400 u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
4402 DEBUGFUNC("ixgbe_write_phy_reg_x550a");
4404 if (hw->mac.ops.acquire_swfw_sync(hw, mask) == IXGBE_SUCCESS) {
4405 status = hw->phy.ops.write_reg_mdi(hw, reg_addr, device_type,
4407 hw->mac.ops.release_swfw_sync(hw, mask);
4409 status = IXGBE_ERR_SWFW_SYNC;
4416 * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
4417 * @hw: pointer to hardware structure
4419 * Handle external Base T PHY interrupt. If high temperature
4420 * failure alarm then return error, else if link status change
4421 * then setup internal/external PHY link
4423 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
4424 * failure alarm, else return PHY access status.
4426 s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
4431 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
4433 if (status != IXGBE_SUCCESS)
4437 return ixgbe_setup_internal_phy(hw);
4439 return IXGBE_SUCCESS;
4443 * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
4444 * @hw: pointer to hardware structure
4445 * @speed: new link speed
4446 * @autoneg_wait_to_complete: true when waiting for completion is needed
4448 * Setup internal/external PHY link speed based on link speed, then set
4449 * external PHY auto advertised link speed.
4451 * Returns error status for any failure
4453 s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
4454 ixgbe_link_speed speed,
4455 bool autoneg_wait_to_complete)
4458 ixgbe_link_speed force_speed;
4460 DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
4462 /* Setup internal/external PHY link speed to iXFI (10G), unless
4463 * only 1G is auto advertised then setup KX link.
4465 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
4466 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
4468 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
4470 /* If X552 and internal link mode is XFI, then setup XFI internal link.
4472 if (hw->mac.type == ixgbe_mac_X550EM_x &&
4473 !(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
4474 status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
4476 if (status != IXGBE_SUCCESS)
4480 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
4484 * ixgbe_check_link_t_X550em - Determine link and speed status
4485 * @hw: pointer to hardware structure
4486 * @speed: pointer to link speed
4487 * @link_up: true when link is up
4488 * @link_up_wait_to_complete: bool used to wait for link up or not
4490 * Check that both the MAC and X557 external PHY have link.
4492 s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
4493 bool *link_up, bool link_up_wait_to_complete)
4496 u16 i, autoneg_status = 0;
4498 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
4499 return IXGBE_ERR_CONFIG;
4501 status = ixgbe_check_mac_link_generic(hw, speed, link_up,
4502 link_up_wait_to_complete);
4504 /* If check link fails or MAC link is not up, then return */
4505 if (status != IXGBE_SUCCESS || !(*link_up))
4508 /* MAC link is up, so check external PHY link.
4509 * X557 PHY. Link status is latching low, and can only be used to detect
4510 * link drop, and not the current status of the link without performing
4511 * back-to-back reads.
4513 for (i = 0; i < 2; i++) {
4514 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
4515 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
4518 if (status != IXGBE_SUCCESS)
4522 /* If external PHY link is not up, then indicate link not up */
4523 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
4526 return IXGBE_SUCCESS;
4530 * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
4531 * @hw: pointer to hardware structure
4533 s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
4537 status = ixgbe_reset_phy_generic(hw);
4539 if (status != IXGBE_SUCCESS)
4542 /* Configure Link Status Alarm and Temperature Threshold interrupts */
4543 return ixgbe_enable_lasi_ext_t_x550em(hw);
4547 * ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
4548 * @hw: pointer to hardware structure
4549 * @led_idx: led number to turn on
4551 s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
4555 DEBUGFUNC("ixgbe_led_on_t_X550em");
4557 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
4558 return IXGBE_ERR_PARAM;
4560 /* To turn on the LED, set mode to ON. */
4561 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4562 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
4563 phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
4564 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4565 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
4567 /* Some designs have the LEDs wired to the MAC */
4568 return ixgbe_led_on_generic(hw, led_idx);
4572 * ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
4573 * @hw: pointer to hardware structure
4574 * @led_idx: led number to turn off
4576 s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
4580 DEBUGFUNC("ixgbe_led_off_t_X550em");
4582 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
4583 return IXGBE_ERR_PARAM;
4585 /* To turn on the LED, set mode to ON. */
4586 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4587 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
4588 phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
4589 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
4590 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
4592 /* Some designs have the LEDs wired to the MAC */
4593 return ixgbe_led_off_generic(hw, led_idx);
4597 * ixgbe_set_fw_drv_ver_x550 - Sends driver version to firmware
4598 * @hw: pointer to the HW structure
4599 * @maj: driver version major number
4600 * @min: driver version minor number
4601 * @build: driver version build number
4602 * @sub: driver version sub build number
4603 * @len: length of driver_ver string
4604 * @driver_ver: driver string
4606 * Sends driver version number to firmware through the manageability
4607 * block. On success return IXGBE_SUCCESS
4608 * else returns IXGBE_ERR_SWFW_SYNC when encountering an error acquiring
4609 * semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
4611 s32 ixgbe_set_fw_drv_ver_x550(struct ixgbe_hw *hw, u8 maj, u8 min,
4612 u8 build, u8 sub, u16 len, const char *driver_ver)
4614 struct ixgbe_hic_drv_info2 fw_cmd;
4615 s32 ret_val = IXGBE_SUCCESS;
4618 DEBUGFUNC("ixgbe_set_fw_drv_ver_x550");
4620 if ((len == 0) || (driver_ver == NULL) ||
4621 (len > sizeof(fw_cmd.driver_string)))
4622 return IXGBE_ERR_INVALID_ARGUMENT;
4624 fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
4625 fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN + len;
4626 fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;
4627 fw_cmd.port_num = (u8)hw->bus.func;
4628 fw_cmd.ver_maj = maj;
4629 fw_cmd.ver_min = min;
4630 fw_cmd.ver_build = build;
4631 fw_cmd.ver_sub = sub;
4632 fw_cmd.hdr.checksum = 0;
4633 memcpy(fw_cmd.driver_string, driver_ver, len);
4634 fw_cmd.hdr.checksum = ixgbe_calculate_checksum((u8 *)&fw_cmd,
4635 (FW_CEM_HDR_LEN + fw_cmd.hdr.buf_len));
4637 for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
4638 ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
4640 IXGBE_HI_COMMAND_TIMEOUT,
4642 if (ret_val != IXGBE_SUCCESS)
4645 if (fw_cmd.hdr.cmd_or_resp.ret_status ==
4646 FW_CEM_RESP_STATUS_SUCCESS)
4647 ret_val = IXGBE_SUCCESS;
4649 ret_val = IXGBE_ERR_HOST_INTERFACE_COMMAND;