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"
43 * ixgbe_init_ops_X550 - Inits func ptrs and MAC type
44 * @hw: pointer to hardware structure
46 * Initialize the function pointers and assign the MAC type for X550.
47 * Does not touch the hardware.
49 s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
51 struct ixgbe_mac_info *mac = &hw->mac;
52 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
55 DEBUGFUNC("ixgbe_init_ops_X550");
57 ret_val = ixgbe_init_ops_X540(hw);
58 mac->ops.dmac_config = ixgbe_dmac_config_X550;
59 mac->ops.dmac_config_tcs = ixgbe_dmac_config_tcs_X550;
60 mac->ops.dmac_update_tcs = ixgbe_dmac_update_tcs_X550;
61 mac->ops.setup_eee = ixgbe_setup_eee_X550;
62 mac->ops.set_source_address_pruning =
63 ixgbe_set_source_address_pruning_X550;
64 mac->ops.set_ethertype_anti_spoofing =
65 ixgbe_set_ethertype_anti_spoofing_X550;
67 mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
68 eeprom->ops.init_params = ixgbe_init_eeprom_params_X550;
69 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
70 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
71 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
72 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
73 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
74 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
75 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
77 mac->ops.disable_mdd = ixgbe_disable_mdd_X550;
78 mac->ops.enable_mdd = ixgbe_enable_mdd_X550;
79 mac->ops.mdd_event = ixgbe_mdd_event_X550;
80 mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
81 mac->ops.disable_rx = ixgbe_disable_rx_x550;
86 * ixgbe_read_cs4227 - Read CS4227 register
87 * @hw: pointer to hardware structure
88 * @reg: register number to write
89 * @value: pointer to receive value read
93 STATIC s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
95 return ixgbe_read_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
99 * ixgbe_write_cs4227 - Write CS4227 register
100 * @hw: pointer to hardware structure
101 * @reg: register number to write
102 * @value: value to write to register
104 * Returns status code
106 STATIC s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
108 return ixgbe_write_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
112 * ixgbe_get_cs4227_status - Return CS4227 status
113 * @hw: pointer to hardware structure
115 * Returns error if CS4227 not successfully initialized
117 STATIC s32 ixgbe_get_cs4227_status(struct ixgbe_hw *hw)
121 u16 reg_slice, reg_val;
124 for (retry = 0; retry < IXGBE_CS4227_RETRIES; ++retry) {
125 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_GLOBAL_ID_LSB,
127 if (status != IXGBE_SUCCESS)
129 if (value == IXGBE_CS4227_GLOBAL_ID_VALUE)
131 msec_delay(IXGBE_CS4227_CHECK_DELAY);
133 if (value != IXGBE_CS4227_GLOBAL_ID_VALUE)
134 return IXGBE_ERR_PHY;
136 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
137 if (status != IXGBE_SUCCESS)
140 /* If this is the first time after power-on, check the ucode.
141 * Otherwise, this will disrupt link on all ports. Because we
142 * can only do this the first time, we must check all ports,
145 if (value != IXGBE_CS4227_SCRATCH_VALUE) {
146 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
147 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
148 status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
149 if (status != IXGBE_SUCCESS)
152 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB;
153 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
154 status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
155 if (status != IXGBE_SUCCESS)
158 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
159 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
160 status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
161 if (status != IXGBE_SUCCESS)
164 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (1 << 12);
165 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
166 status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
167 if (status != IXGBE_SUCCESS)
173 /* Verify that the ucode is operational on all ports. */
174 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
176 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
177 if (status != IXGBE_SUCCESS)
180 return IXGBE_ERR_PHY;
182 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB;
184 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
185 if (status != IXGBE_SUCCESS)
188 return IXGBE_ERR_PHY;
190 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
192 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
193 if (status != IXGBE_SUCCESS)
196 return IXGBE_ERR_PHY;
198 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (1 << 12);
200 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
201 if (status != IXGBE_SUCCESS)
204 return IXGBE_ERR_PHY;
206 /* Set scratch indicating that the diagnostic was successful. */
207 status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
208 IXGBE_CS4227_SCRATCH_VALUE);
209 if (status != IXGBE_SUCCESS)
211 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
212 if (status != IXGBE_SUCCESS)
214 if (value != IXGBE_CS4227_SCRATCH_VALUE)
215 return IXGBE_ERR_PHY;
217 return IXGBE_SUCCESS;
221 * ixgbe_read_pe - Read register from port expander
222 * @hw: pointer to hardware structure
223 * @reg: register number to read
224 * @value: pointer to receive read value
226 * Returns status code
228 STATIC s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
232 status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
233 if (status != IXGBE_SUCCESS)
234 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
235 "port expander access failed with %d\n", status);
240 * ixgbe_write_pe - Write register to port expander
241 * @hw: pointer to hardware structure
242 * @reg: register number to write
243 * @value: value to write
245 * Returns status code
247 STATIC s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
251 status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
252 if (status != IXGBE_SUCCESS)
253 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
254 "port expander access failed with %d\n", status);
259 * ixgbe_reset_cs4227 - Reset CS4227 using port expander
260 * @hw: pointer to hardware structure
264 STATIC s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
269 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
270 if (status != IXGBE_SUCCESS)
272 reg |= IXGBE_PE_BIT1;
273 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
274 if (status != IXGBE_SUCCESS)
277 status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, ®);
278 if (status != IXGBE_SUCCESS)
280 reg &= ~IXGBE_PE_BIT1;
281 status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
282 if (status != IXGBE_SUCCESS)
285 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
286 if (status != IXGBE_SUCCESS)
288 reg &= ~IXGBE_PE_BIT1;
289 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
290 if (status != IXGBE_SUCCESS)
293 usec_delay(IXGBE_CS4227_RESET_HOLD);
295 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
296 if (status != IXGBE_SUCCESS)
298 reg |= IXGBE_PE_BIT1;
299 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
300 if (status != IXGBE_SUCCESS)
303 msec_delay(IXGBE_CS4227_RESET_DELAY);
305 return IXGBE_SUCCESS;
309 * ixgbe_check_cs4227 - Check CS4227 and reset as needed
310 * @hw: pointer to hardware structure
312 STATIC void ixgbe_check_cs4227(struct ixgbe_hw *hw)
314 u32 swfw_mask = hw->phy.phy_semaphore_mask;
318 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
319 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
320 if (status != IXGBE_SUCCESS) {
321 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
322 "semaphore failed with %d\n", status);
325 status = ixgbe_get_cs4227_status(hw);
326 if (status == IXGBE_SUCCESS) {
327 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
328 msec_delay(hw->eeprom.semaphore_delay);
331 ixgbe_reset_cs4227(hw);
332 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
333 msec_delay(hw->eeprom.semaphore_delay);
335 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
336 "Unable to initialize CS4227, err=%d\n", status);
340 * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
341 * @hw: pointer to hardware structure
343 STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
345 u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
347 if (hw->bus.lan_id) {
348 esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
349 esdp |= IXGBE_ESDP_SDP1_DIR;
351 esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
352 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
353 IXGBE_WRITE_FLUSH(hw);
357 * ixgbe_identify_phy_x550em - Get PHY type based on device id
358 * @hw: pointer to hardware structure
362 STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
364 switch (hw->device_id) {
365 case IXGBE_DEV_ID_X550EM_X_SFP:
366 /* set up for CS4227 usage */
367 hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
368 ixgbe_setup_mux_ctl(hw);
369 ixgbe_check_cs4227(hw);
371 return ixgbe_identify_module_generic(hw);
373 case IXGBE_DEV_ID_X550EM_X_KX4:
374 hw->phy.type = ixgbe_phy_x550em_kx4;
376 case IXGBE_DEV_ID_X550EM_X_KR:
377 hw->phy.type = ixgbe_phy_x550em_kr;
379 case IXGBE_DEV_ID_X550EM_X_1G_T:
380 case IXGBE_DEV_ID_X550EM_X_10G_T:
381 return ixgbe_identify_phy_generic(hw);
385 return IXGBE_SUCCESS;
388 STATIC s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
389 u32 device_type, u16 *phy_data)
391 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
392 return IXGBE_NOT_IMPLEMENTED;
395 STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
396 u32 device_type, u16 phy_data)
398 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
399 return IXGBE_NOT_IMPLEMENTED;
403 * ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
404 * @hw: pointer to hardware structure
406 * Initialize the function pointers and for MAC type X550EM.
407 * Does not touch the hardware.
409 s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
411 struct ixgbe_mac_info *mac = &hw->mac;
412 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
413 struct ixgbe_phy_info *phy = &hw->phy;
416 DEBUGFUNC("ixgbe_init_ops_X550EM");
418 /* Similar to X550 so start there. */
419 ret_val = ixgbe_init_ops_X550(hw);
421 /* Since this function eventually calls
422 * ixgbe_init_ops_540 by design, we are setting
423 * the pointers to NULL explicitly here to overwrite
424 * the values being set in the x540 function.
426 /* Thermal sensor not supported in x550EM */
427 mac->ops.get_thermal_sensor_data = NULL;
428 mac->ops.init_thermal_sensor_thresh = NULL;
429 mac->thermal_sensor_enabled = false;
431 /* FCOE not supported in x550EM */
432 mac->ops.get_san_mac_addr = NULL;
433 mac->ops.set_san_mac_addr = NULL;
434 mac->ops.get_wwn_prefix = NULL;
435 mac->ops.get_fcoe_boot_status = NULL;
437 /* IPsec not supported in x550EM */
438 mac->ops.disable_sec_rx_path = NULL;
439 mac->ops.enable_sec_rx_path = NULL;
441 /* AUTOC register is not present in x550EM. */
442 mac->ops.prot_autoc_read = NULL;
443 mac->ops.prot_autoc_write = NULL;
445 /* X550EM bus type is internal*/
446 hw->bus.type = ixgbe_bus_type_internal;
447 mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
449 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
450 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
451 mac->ops.get_media_type = ixgbe_get_media_type_X550em;
452 mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
453 mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
454 mac->ops.reset_hw = ixgbe_reset_hw_X550em;
455 mac->ops.get_supported_physical_layer =
456 ixgbe_get_supported_physical_layer_X550em;
458 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
459 mac->ops.setup_fc = ixgbe_setup_fc_generic;
461 mac->ops.setup_fc = ixgbe_setup_fc_X550em;
463 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
464 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
466 if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
467 mac->ops.setup_eee = NULL;
470 phy->ops.init = ixgbe_init_phy_ops_X550em;
471 phy->ops.identify = ixgbe_identify_phy_x550em;
472 if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
473 phy->ops.set_phy_power = NULL;
477 eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
478 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
479 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
480 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
481 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
482 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
483 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
484 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
490 * ixgbe_dmac_config_X550
491 * @hw: pointer to hardware structure
493 * Configure DMA coalescing. If enabling dmac, dmac is activated.
494 * When disabling dmac, dmac enable dmac bit is cleared.
496 s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
498 u32 reg, high_pri_tc;
500 DEBUGFUNC("ixgbe_dmac_config_X550");
502 /* Disable DMA coalescing before configuring */
503 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
504 reg &= ~IXGBE_DMACR_DMAC_EN;
505 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
507 /* Disable DMA Coalescing if the watchdog timer is 0 */
508 if (!hw->mac.dmac_config.watchdog_timer)
511 ixgbe_dmac_config_tcs_X550(hw);
513 /* Configure DMA Coalescing Control Register */
514 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
516 /* Set the watchdog timer in units of 40.96 usec */
517 reg &= ~IXGBE_DMACR_DMACWT_MASK;
518 reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
520 reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
521 /* If fcoe is enabled, set high priority traffic class */
522 if (hw->mac.dmac_config.fcoe_en) {
523 high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
524 reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
525 IXGBE_DMACR_HIGH_PRI_TC_MASK);
527 reg |= IXGBE_DMACR_EN_MNG_IND;
529 /* Enable DMA coalescing after configuration */
530 reg |= IXGBE_DMACR_DMAC_EN;
531 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
534 return IXGBE_SUCCESS;
538 * ixgbe_dmac_config_tcs_X550
539 * @hw: pointer to hardware structure
541 * Configure DMA coalescing threshold per TC. The dmac enable bit must
542 * be cleared before configuring.
544 s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
546 u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
548 DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
550 /* Configure DMA coalescing enabled */
551 switch (hw->mac.dmac_config.link_speed) {
552 case IXGBE_LINK_SPEED_100_FULL:
553 pb_headroom = IXGBE_DMACRXT_100M;
555 case IXGBE_LINK_SPEED_1GB_FULL:
556 pb_headroom = IXGBE_DMACRXT_1G;
559 pb_headroom = IXGBE_DMACRXT_10G;
563 maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
564 IXGBE_MHADD_MFS_SHIFT) / 1024);
566 /* Set the per Rx packet buffer receive threshold */
567 for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
568 reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
569 reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
571 if (tc < hw->mac.dmac_config.num_tcs) {
573 rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
574 rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
575 IXGBE_RXPBSIZE_SHIFT;
577 /* Calculate receive buffer threshold in kilobytes */
578 if (rx_pb_size > pb_headroom)
579 rx_pb_size = rx_pb_size - pb_headroom;
583 /* Minimum of MFS shall be set for DMCTH */
584 reg |= (rx_pb_size > maxframe_size_kb) ?
585 rx_pb_size : maxframe_size_kb;
587 IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
589 return IXGBE_SUCCESS;
593 * ixgbe_dmac_update_tcs_X550
594 * @hw: pointer to hardware structure
596 * Disables dmac, updates per TC settings, and then enables dmac.
598 s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
602 DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
604 /* Disable DMA coalescing before configuring */
605 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
606 reg &= ~IXGBE_DMACR_DMAC_EN;
607 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
609 ixgbe_dmac_config_tcs_X550(hw);
611 /* Enable DMA coalescing after configuration */
612 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
613 reg |= IXGBE_DMACR_DMAC_EN;
614 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
616 return IXGBE_SUCCESS;
620 * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
621 * @hw: pointer to hardware structure
623 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
624 * ixgbe_hw struct in order to set up EEPROM access.
626 s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
628 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
632 DEBUGFUNC("ixgbe_init_eeprom_params_X550");
634 if (eeprom->type == ixgbe_eeprom_uninitialized) {
635 eeprom->semaphore_delay = 10;
636 eeprom->type = ixgbe_flash;
638 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
639 eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
640 IXGBE_EEC_SIZE_SHIFT);
641 eeprom->word_size = 1 << (eeprom_size +
642 IXGBE_EEPROM_WORD_SIZE_SHIFT);
644 DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
645 eeprom->type, eeprom->word_size);
648 return IXGBE_SUCCESS;
652 * ixgbe_setup_eee_X550 - Enable/disable EEE support
653 * @hw: pointer to the HW structure
654 * @enable_eee: boolean flag to enable EEE
656 * Enable/disable EEE based on enable_eee flag.
657 * Auto-negotiation must be started after BASE-T EEE bits in PHY register 7.3C
661 s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
668 DEBUGFUNC("ixgbe_setup_eee_X550");
670 eeer = IXGBE_READ_REG(hw, IXGBE_EEER);
671 /* Enable or disable EEE per flag */
673 eeer |= (IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
675 if (hw->device_id == IXGBE_DEV_ID_X550T) {
676 /* Advertise EEE capability */
677 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
678 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
680 autoneg_eee_reg |= (IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
681 IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
682 IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
684 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
685 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
686 } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
687 status = ixgbe_read_iosf_sb_reg_x550(hw,
688 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
689 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
690 if (status != IXGBE_SUCCESS)
693 link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
694 IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;
696 /* Must disable FEC when EEE is enabled. */
697 link_reg &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ |
698 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC);
700 status = ixgbe_write_iosf_sb_reg_x550(hw,
701 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
702 IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
703 if (status != IXGBE_SUCCESS)
707 eeer &= ~(IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
709 if (hw->device_id == IXGBE_DEV_ID_X550T) {
710 /* Disable advertised EEE capability */
711 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
712 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
714 autoneg_eee_reg &= ~(IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
715 IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
716 IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
718 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
719 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
720 } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
721 status = ixgbe_read_iosf_sb_reg_x550(hw,
722 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
723 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
724 if (status != IXGBE_SUCCESS)
727 link_reg &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
728 IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX);
730 /* Enable FEC when EEE is disabled. */
731 link_reg |= (IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ |
732 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC);
734 status = ixgbe_write_iosf_sb_reg_x550(hw,
735 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
736 IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
737 if (status != IXGBE_SUCCESS)
741 IXGBE_WRITE_REG(hw, IXGBE_EEER, eeer);
743 return IXGBE_SUCCESS;
747 * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
748 * @hw: pointer to hardware structure
749 * @enable: enable or disable source address pruning
750 * @pool: Rx pool to set source address pruning for
752 void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
757 /* max rx pool is 63 */
761 pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
762 pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
765 pfflp |= (1ULL << pool);
767 pfflp &= ~(1ULL << pool);
769 IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
770 IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
774 * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
775 * @hw: pointer to hardware structure
776 * @enable: enable or disable switch for Ethertype anti-spoofing
777 * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
780 void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
783 int vf_target_reg = vf >> 3;
784 int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
787 DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
789 pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
791 pfvfspoof |= (1 << vf_target_shift);
793 pfvfspoof &= ~(1 << vf_target_shift);
795 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
799 * ixgbe_iosf_wait - Wait for IOSF command completion
800 * @hw: pointer to hardware structure
801 * @ctrl: pointer to location to receive final IOSF control value
803 * Returns failing status on timeout
805 * Note: ctrl can be NULL if the IOSF control register value is not needed
807 STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
811 /* Check every 10 usec to see if the address cycle completed.
812 * The SB IOSF BUSY bit will clear when the operation is
815 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
816 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
817 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
823 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
824 ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
825 return IXGBE_ERR_PHY;
828 return IXGBE_SUCCESS;
832 * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
834 * @hw: pointer to hardware structure
835 * @reg_addr: 32 bit PHY register to write
836 * @device_type: 3 bit device type
837 * @data: Data to write to the register
839 s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
840 u32 device_type, u32 data)
842 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
846 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
847 if (ret != IXGBE_SUCCESS)
850 ret = ixgbe_iosf_wait(hw, NULL);
851 if (ret != IXGBE_SUCCESS)
854 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
855 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
857 /* Write IOSF control register */
858 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
860 /* Write IOSF data register */
861 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
863 ret = ixgbe_iosf_wait(hw, &command);
865 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
866 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
867 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
868 ERROR_REPORT2(IXGBE_ERROR_POLLING,
869 "Failed to write, error %x\n", error);
874 ixgbe_release_swfw_semaphore(hw, gssr);
879 * ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
881 * @hw: pointer to hardware structure
882 * @reg_addr: 32 bit PHY register to write
883 * @device_type: 3 bit device type
884 * @phy_data: Pointer to read data from the register
886 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
887 u32 device_type, u32 *data)
889 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
893 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
894 if (ret != IXGBE_SUCCESS)
897 ret = ixgbe_iosf_wait(hw, NULL);
898 if (ret != IXGBE_SUCCESS)
901 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
902 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
904 /* Write IOSF control register */
905 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
907 ret = ixgbe_iosf_wait(hw, &command);
909 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
910 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
911 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
912 ERROR_REPORT2(IXGBE_ERROR_POLLING,
913 "Failed to read, error %x\n", error);
917 if (ret == IXGBE_SUCCESS)
918 *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
921 ixgbe_release_swfw_semaphore(hw, gssr);
926 * ixgbe_disable_mdd_X550
927 * @hw: pointer to hardware structure
929 * Disable malicious driver detection
931 void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
935 DEBUGFUNC("ixgbe_disable_mdd_X550");
937 /* Disable MDD for TX DMA and interrupt */
938 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
939 reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
940 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
942 /* Disable MDD for RX and interrupt */
943 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
944 reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
945 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
949 * ixgbe_enable_mdd_X550
950 * @hw: pointer to hardware structure
952 * Enable malicious driver detection
954 void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
958 DEBUGFUNC("ixgbe_enable_mdd_X550");
960 /* Enable MDD for TX DMA and interrupt */
961 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
962 reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
963 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
965 /* Enable MDD for RX and interrupt */
966 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
967 reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
968 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
972 * ixgbe_restore_mdd_vf_X550
973 * @hw: pointer to hardware structure
976 * Restore VF that was disabled during malicious driver detection event
978 void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
980 u32 idx, reg, num_qs, start_q, bitmask;
982 DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
984 /* Map VF to queues */
985 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
986 switch (reg & IXGBE_MRQC_MRQE_MASK) {
987 case IXGBE_MRQC_VMDQRT8TCEN:
988 num_qs = 8; /* 16 VFs / pools */
989 bitmask = 0x000000FF;
991 case IXGBE_MRQC_VMDQRSS32EN:
992 case IXGBE_MRQC_VMDQRT4TCEN:
993 num_qs = 4; /* 32 VFs / pools */
994 bitmask = 0x0000000F;
996 default: /* 64 VFs / pools */
998 bitmask = 0x00000003;
1001 start_q = vf * num_qs;
1003 /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
1006 reg |= (bitmask << (start_q % 32));
1007 IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
1008 IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
1012 * ixgbe_mdd_event_X550
1013 * @hw: pointer to hardware structure
1014 * @vf_bitmap: vf bitmap of malicious vfs
1016 * Handle malicious driver detection event.
1018 void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
1021 u32 i, j, reg, q, shift, vf, idx;
1023 DEBUGFUNC("ixgbe_mdd_event_X550");
1025 /* figure out pool size for mapping to vf's */
1026 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1027 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1028 case IXGBE_MRQC_VMDQRT8TCEN:
1029 shift = 3; /* 16 VFs / pools */
1031 case IXGBE_MRQC_VMDQRSS32EN:
1032 case IXGBE_MRQC_VMDQRT4TCEN:
1033 shift = 2; /* 32 VFs / pools */
1036 shift = 1; /* 64 VFs / pools */
1040 /* Read WQBR_TX and WQBR_RX and check for malicious queues */
1041 for (i = 0; i < 4; i++) {
1042 wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
1043 wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
1048 /* Get malicious queue */
1049 for (j = 0; j < 32 && wqbr; j++) {
1051 if (!(wqbr & (1 << j)))
1054 /* Get queue from bitmask */
1057 /* Map queue to vf */
1060 /* Set vf bit in vf_bitmap */
1062 vf_bitmap[idx] |= (1 << (vf % 32));
1069 * ixgbe_get_media_type_X550em - Get media type
1070 * @hw: pointer to hardware structure
1072 * Returns the media type (fiber, copper, backplane)
1074 enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1076 enum ixgbe_media_type media_type;
1078 DEBUGFUNC("ixgbe_get_media_type_X550em");
1080 /* Detect if there is a copper PHY attached. */
1081 switch (hw->device_id) {
1082 case IXGBE_DEV_ID_X550EM_X_KR:
1083 case IXGBE_DEV_ID_X550EM_X_KX4:
1084 media_type = ixgbe_media_type_backplane;
1086 case IXGBE_DEV_ID_X550EM_X_SFP:
1087 media_type = ixgbe_media_type_fiber;
1089 case IXGBE_DEV_ID_X550EM_X_1G_T:
1090 case IXGBE_DEV_ID_X550EM_X_10G_T:
1091 media_type = ixgbe_media_type_copper;
1094 media_type = ixgbe_media_type_unknown;
1101 * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
1102 * @hw: pointer to hardware structure
1103 * @linear: true if SFP module is linear
1105 STATIC s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
1107 DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
1109 switch (hw->phy.sfp_type) {
1110 case ixgbe_sfp_type_not_present:
1111 return IXGBE_ERR_SFP_NOT_PRESENT;
1112 case ixgbe_sfp_type_da_cu_core0:
1113 case ixgbe_sfp_type_da_cu_core1:
1116 case ixgbe_sfp_type_srlr_core0:
1117 case ixgbe_sfp_type_srlr_core1:
1118 case ixgbe_sfp_type_da_act_lmt_core0:
1119 case ixgbe_sfp_type_da_act_lmt_core1:
1120 case ixgbe_sfp_type_1g_sx_core0:
1121 case ixgbe_sfp_type_1g_sx_core1:
1122 case ixgbe_sfp_type_1g_lx_core0:
1123 case ixgbe_sfp_type_1g_lx_core1:
1126 case ixgbe_sfp_type_unknown:
1127 case ixgbe_sfp_type_1g_cu_core0:
1128 case ixgbe_sfp_type_1g_cu_core1:
1130 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1133 return IXGBE_SUCCESS;
1137 * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
1138 * @hw: pointer to hardware structure
1140 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1142 s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
1147 DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
1149 status = ixgbe_identify_module_generic(hw);
1151 if (status != IXGBE_SUCCESS)
1154 /* Check if SFP module is supported */
1155 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1161 * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
1162 * @hw: pointer to hardware structure
1164 s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
1169 DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
1171 /* Check if SFP module is supported */
1172 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1174 if (status != IXGBE_SUCCESS)
1177 ixgbe_init_mac_link_ops_X550em(hw);
1178 hw->phy.ops.reset = NULL;
1180 return IXGBE_SUCCESS;
1184 * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
1185 * @hw: pointer to hardware structure
1187 void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
1189 struct ixgbe_mac_info *mac = &hw->mac;
1191 DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
1193 switch (hw->mac.ops.get_media_type(hw)) {
1194 case ixgbe_media_type_fiber:
1195 /* CS4227 does not support autoneg, so disable the laser control
1196 * functions for SFP+ fiber
1198 mac->ops.disable_tx_laser = NULL;
1199 mac->ops.enable_tx_laser = NULL;
1200 mac->ops.flap_tx_laser = NULL;
1201 mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
1202 mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_x550em;
1203 mac->ops.set_rate_select_speed =
1204 ixgbe_set_soft_rate_select_speed;
1206 case ixgbe_media_type_copper:
1207 mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
1208 mac->ops.check_link = ixgbe_check_link_t_X550em;
1216 * ixgbe_get_link_capabilities_x550em - Determines link capabilities
1217 * @hw: pointer to hardware structure
1218 * @speed: pointer to link speed
1219 * @autoneg: true when autoneg or autotry is enabled
1221 s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
1222 ixgbe_link_speed *speed,
1225 DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
1228 if (hw->phy.media_type == ixgbe_media_type_fiber) {
1230 /* CS4227 SFP must not enable auto-negotiation */
1233 /* Check if 1G SFP module. */
1234 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1235 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
1236 || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1237 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
1238 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1239 return IXGBE_SUCCESS;
1242 /* Link capabilities are based on SFP */
1243 if (hw->phy.multispeed_fiber)
1244 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1245 IXGBE_LINK_SPEED_1GB_FULL;
1247 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1249 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1250 IXGBE_LINK_SPEED_1GB_FULL;
1254 return IXGBE_SUCCESS;
1258 * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
1259 * @hw: pointer to hardware structure
1260 * @lsc: pointer to boolean flag which indicates whether external Base T
1261 * PHY interrupt is lsc
1263 * Determime if external Base T PHY interrupt cause is high temperature
1264 * failure alarm or link status change.
1266 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
1267 * failure alarm, else return PHY access status.
1269 STATIC s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
1276 /* Vendor alarm triggered */
1277 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1278 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1281 if (status != IXGBE_SUCCESS ||
1282 !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
1285 /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
1286 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
1287 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1290 if (status != IXGBE_SUCCESS ||
1291 !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1292 IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
1295 /* High temperature failure alarm triggered */
1296 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
1297 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1300 if (status != IXGBE_SUCCESS)
1303 /* If high temperature failure, then return over temp error and exit */
1304 if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
1305 /* power down the PHY in case the PHY FW didn't already */
1306 ixgbe_set_copper_phy_power(hw, false);
1307 return IXGBE_ERR_OVERTEMP;
1310 /* Vendor alarm 2 triggered */
1311 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1312 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1314 if (status != IXGBE_SUCCESS ||
1315 !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
1318 /* link connect/disconnect event occurred */
1319 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
1320 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1322 if (status != IXGBE_SUCCESS)
1326 if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
1329 return IXGBE_SUCCESS;
1333 * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
1334 * @hw: pointer to hardware structure
1336 * Enable link status change and temperature failure alarm for the external
1339 * Returns PHY access status
1341 STATIC s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
1347 /* Clear interrupt flags */
1348 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
1350 /* Enable link status change alarm */
1351 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1352 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1354 if (status != IXGBE_SUCCESS)
1357 reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
1359 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1360 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
1362 if (status != IXGBE_SUCCESS)
1365 /* Enables high temperature failure alarm */
1366 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1367 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1370 if (status != IXGBE_SUCCESS)
1373 reg |= IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN;
1375 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1376 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1379 if (status != IXGBE_SUCCESS)
1382 /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
1383 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1384 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1387 if (status != IXGBE_SUCCESS)
1390 reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1391 IXGBE_MDIO_GLOBAL_ALARM_1_INT);
1393 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1394 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1397 if (status != IXGBE_SUCCESS)
1400 /* Enable chip-wide vendor alarm */
1401 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1402 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1405 if (status != IXGBE_SUCCESS)
1408 reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
1410 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1411 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1418 * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
1419 * @hw: pointer to hardware structure
1421 * Initialize any function pointers that were not able to be
1422 * set during init_shared_code because the PHY/SFP type was
1423 * not known. Perform the SFP init if necessary.
1425 s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
1427 struct ixgbe_phy_info *phy = &hw->phy;
1430 DEBUGFUNC("ixgbe_init_phy_ops_X550em");
1432 hw->mac.ops.set_lan_id(hw);
1434 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
1435 phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
1436 ixgbe_setup_mux_ctl(hw);
1438 phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
1441 /* Identify the PHY or SFP module */
1442 ret_val = phy->ops.identify(hw);
1443 if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED)
1446 /* Setup function pointers based on detected hardware */
1447 ixgbe_init_mac_link_ops_X550em(hw);
1448 if (phy->sfp_type != ixgbe_sfp_type_unknown)
1449 phy->ops.reset = NULL;
1451 /* Set functions pointers based on phy type */
1452 switch (hw->phy.type) {
1453 case ixgbe_phy_x550em_kx4:
1454 phy->ops.setup_link = ixgbe_setup_kx4_x550em;
1455 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1456 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1458 case ixgbe_phy_x550em_kr:
1459 phy->ops.setup_link = ixgbe_setup_kr_x550em;
1460 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1461 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1463 case ixgbe_phy_x550em_ext_t:
1464 phy->ops.setup_internal_link =
1465 ixgbe_setup_internal_phy_t_x550em;
1466 phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
1467 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
1468 phy->ops.reset = ixgbe_reset_phy_t_X550em;
1477 * ixgbe_reset_hw_X550em - Perform hardware reset
1478 * @hw: pointer to hardware structure
1480 * Resets the hardware by resetting the transmit and receive units, masks
1481 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
1484 s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
1486 ixgbe_link_speed link_speed;
1490 bool link_up = false;
1492 DEBUGFUNC("ixgbe_reset_hw_X550em");
1494 /* Call adapter stop to disable Tx/Rx and clear interrupts */
1495 status = hw->mac.ops.stop_adapter(hw);
1496 if (status != IXGBE_SUCCESS)
1499 /* flush pending Tx transactions */
1500 ixgbe_clear_tx_pending(hw);
1502 /* PHY ops must be identified and initialized prior to reset */
1504 /* Identify PHY and related function pointers */
1505 status = hw->phy.ops.init(hw);
1507 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1510 /* start the external PHY */
1511 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
1512 status = ixgbe_init_ext_t_x550em(hw);
1517 /* Setup SFP module if there is one present. */
1518 if (hw->phy.sfp_setup_needed) {
1519 status = hw->mac.ops.setup_sfp(hw);
1520 hw->phy.sfp_setup_needed = false;
1523 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1527 if (!hw->phy.reset_disable && hw->phy.ops.reset)
1528 hw->phy.ops.reset(hw);
1531 /* Issue global reset to the MAC. Needs to be SW reset if link is up.
1532 * If link reset is used when link is up, it might reset the PHY when
1533 * mng is using it. If link is down or the flag to force full link
1534 * reset is set, then perform link reset.
1536 ctrl = IXGBE_CTRL_LNK_RST;
1537 if (!hw->force_full_reset) {
1538 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
1540 ctrl = IXGBE_CTRL_RST;
1543 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
1544 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
1545 IXGBE_WRITE_FLUSH(hw);
1547 /* Poll for reset bit to self-clear meaning reset is complete */
1548 for (i = 0; i < 10; i++) {
1550 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
1551 if (!(ctrl & IXGBE_CTRL_RST_MASK))
1555 if (ctrl & IXGBE_CTRL_RST_MASK) {
1556 status = IXGBE_ERR_RESET_FAILED;
1557 DEBUGOUT("Reset polling failed to complete.\n");
1562 /* Double resets are required for recovery from certain error
1563 * conditions. Between resets, it is necessary to stall to
1564 * allow time for any pending HW events to complete.
1566 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
1567 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
1571 /* Store the permanent mac address */
1572 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
1574 /* Store MAC address from RAR0, clear receive address registers, and
1575 * clear the multicast table. Also reset num_rar_entries to 128,
1576 * since we modify this value when programming the SAN MAC address.
1578 hw->mac.num_rar_entries = 128;
1579 hw->mac.ops.init_rx_addrs(hw);
1582 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
1583 ixgbe_setup_mux_ctl(hw);
1589 * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
1590 * @hw: pointer to hardware structure
1592 s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
1597 status = hw->phy.ops.read_reg(hw,
1598 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
1599 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1602 if (status != IXGBE_SUCCESS)
1605 /* If PHY FW reset completed bit is set then this is the first
1606 * SW instance after a power on so the PHY FW must be un-stalled.
1608 if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
1609 status = hw->phy.ops.read_reg(hw,
1610 IXGBE_MDIO_GLOBAL_RES_PR_10,
1611 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1614 if (status != IXGBE_SUCCESS)
1617 reg &= ~IXGBE_MDIO_POWER_UP_STALL;
1619 status = hw->phy.ops.write_reg(hw,
1620 IXGBE_MDIO_GLOBAL_RES_PR_10,
1621 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1624 if (status != IXGBE_SUCCESS)
1632 * ixgbe_setup_kr_x550em - Configure the KR PHY.
1633 * @hw: pointer to hardware structure
1635 * Configures the integrated KR PHY.
1637 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
1642 status = ixgbe_read_iosf_sb_reg_x550(hw,
1643 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1644 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1648 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1649 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
1650 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
1652 /* Advertise 10G support. */
1653 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1654 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
1656 /* Advertise 1G support. */
1657 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1658 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
1660 /* Restart auto-negotiation. */
1661 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1662 status = ixgbe_write_iosf_sb_reg_x550(hw,
1663 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1664 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1670 * ixgbe_setup_kx4_x550em - Configure the KX4 PHY.
1671 * @hw: pointer to hardware structure
1673 * Configures the integrated KX4 PHY.
1675 s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw)
1680 status = ixgbe_read_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
1681 IXGBE_SB_IOSF_TARGET_KX4_PCS, ®_val);
1685 reg_val &= ~(IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4 |
1686 IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX);
1688 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_ENABLE;
1690 /* Advertise 10G support. */
1691 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1692 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4;
1694 /* Advertise 1G support. */
1695 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1696 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX;
1698 /* Restart auto-negotiation. */
1699 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_RESTART;
1700 status = ixgbe_write_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
1701 IXGBE_SB_IOSF_TARGET_KX4_PCS, reg_val);
1707 * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
1708 * @hw: pointer to hardware structure
1709 * @speed: the link speed to force
1711 * Configures the integrated KR PHY to use iXFI mode. Used to connect an
1712 * internal and external PHY at a specific speed, without autonegotiation.
1714 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
1719 /* Disable AN and force speed to 10G Serial. */
1720 status = ixgbe_read_iosf_sb_reg_x550(hw,
1721 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1722 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1723 if (status != IXGBE_SUCCESS)
1726 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1727 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1729 /* Select forced link speed for internal PHY. */
1731 case IXGBE_LINK_SPEED_10GB_FULL:
1732 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
1734 case IXGBE_LINK_SPEED_1GB_FULL:
1735 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1738 /* Other link speeds are not supported by internal KR PHY. */
1739 return IXGBE_ERR_LINK_SETUP;
1742 status = ixgbe_write_iosf_sb_reg_x550(hw,
1743 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1744 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1745 if (status != IXGBE_SUCCESS)
1748 /* Disable training protocol FSM. */
1749 status = ixgbe_read_iosf_sb_reg_x550(hw,
1750 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1751 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1752 if (status != IXGBE_SUCCESS)
1754 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
1755 status = ixgbe_write_iosf_sb_reg_x550(hw,
1756 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1757 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1758 if (status != IXGBE_SUCCESS)
1761 /* Disable Flex from training TXFFE. */
1762 status = ixgbe_read_iosf_sb_reg_x550(hw,
1763 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
1764 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1765 if (status != IXGBE_SUCCESS)
1767 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
1768 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
1769 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
1770 status = ixgbe_write_iosf_sb_reg_x550(hw,
1771 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
1772 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1773 if (status != IXGBE_SUCCESS)
1775 status = ixgbe_read_iosf_sb_reg_x550(hw,
1776 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
1777 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1778 if (status != IXGBE_SUCCESS)
1780 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
1781 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
1782 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
1783 status = ixgbe_write_iosf_sb_reg_x550(hw,
1784 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
1785 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1786 if (status != IXGBE_SUCCESS)
1789 /* Enable override for coefficients. */
1790 status = ixgbe_read_iosf_sb_reg_x550(hw,
1791 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
1792 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1793 if (status != IXGBE_SUCCESS)
1795 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
1796 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
1797 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
1798 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
1799 status = ixgbe_write_iosf_sb_reg_x550(hw,
1800 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
1801 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1802 if (status != IXGBE_SUCCESS)
1805 /* Toggle port SW reset by AN reset. */
1806 status = ixgbe_read_iosf_sb_reg_x550(hw,
1807 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1808 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1809 if (status != IXGBE_SUCCESS)
1811 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1812 status = ixgbe_write_iosf_sb_reg_x550(hw,
1813 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1814 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1820 * ixgbe_setup_mac_link_sfp_x550em - Configure the CS4227 & KR PHY for SFP
1821 * @hw: pointer to hardware structure
1823 * Configure the external CS4227 PHY and the integrated KR PHY for SFP support.
1825 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
1826 ixgbe_link_speed speed,
1827 bool autoneg_wait_to_complete)
1830 u16 reg_slice, reg_val;
1831 bool setup_linear = false;
1832 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
1834 /* Check if SFP module is supported and linear */
1835 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
1837 /* If no SFP module present, then return success. Return success since
1838 * there is no reason to configure CS4227 and SFP not present error is
1839 * not excepted in the setup MAC link flow.
1841 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
1842 return IXGBE_SUCCESS;
1844 if (ret_val != IXGBE_SUCCESS)
1847 /* Configure CS4227 for LINE connection rate then type. */
1848 reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB + (hw->bus.lan_id << 12);
1849 reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
1850 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1853 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
1855 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
1857 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1858 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1861 /* Configure CS4227 for HOST connection rate then type. */
1862 reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB + (hw->bus.lan_id << 12);
1863 reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
1864 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1867 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (hw->bus.lan_id << 12);
1869 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
1871 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1872 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1875 /* Configure the internal PHY. */
1876 ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
1882 * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
1883 * @hw: point to hardware structure
1885 * Configures the link between the integrated KR PHY and the external X557 PHY
1886 * The driver will call this function when it gets a link status change
1887 * interrupt from the X557 PHY. This function configures the link speed
1888 * between the PHYs to match the link speed of the BASE-T link.
1890 * A return of a non-zero value indicates an error, and the base driver should
1891 * not report link up.
1893 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
1896 u16 autoneg_status, speed;
1897 ixgbe_link_speed force_speed;
1899 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
1900 return IXGBE_ERR_CONFIG;
1902 /* read this twice back to back to indicate current status */
1903 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
1904 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1906 if (status != IXGBE_SUCCESS)
1909 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
1910 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1912 if (status != IXGBE_SUCCESS)
1915 /* If link is not up, then there is no setup necessary so return */
1916 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
1917 return IXGBE_SUCCESS;
1919 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
1920 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1923 /* clear everything but the speed and duplex bits */
1924 speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
1927 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
1928 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
1930 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
1931 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
1934 /* Internal PHY does not support anything else */
1935 return IXGBE_ERR_INVALID_LINK_SETTINGS;
1938 return ixgbe_setup_ixfi_x550em(hw, &force_speed);
1942 * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
1943 * @hw: pointer to hardware structure
1945 * Configures the integrated KR PHY to use internal loopback mode.
1947 s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
1952 /* Disable AN and force speed to 10G Serial. */
1953 status = ixgbe_read_iosf_sb_reg_x550(hw,
1954 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1955 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1956 if (status != IXGBE_SUCCESS)
1958 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1959 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1960 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
1961 status = ixgbe_write_iosf_sb_reg_x550(hw,
1962 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1963 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1964 if (status != IXGBE_SUCCESS)
1967 /* Set near-end loopback clocks. */
1968 status = ixgbe_read_iosf_sb_reg_x550(hw,
1969 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
1970 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1971 if (status != IXGBE_SUCCESS)
1973 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
1974 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
1975 status = ixgbe_write_iosf_sb_reg_x550(hw,
1976 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
1977 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1978 if (status != IXGBE_SUCCESS)
1981 /* Set loopback enable. */
1982 status = ixgbe_read_iosf_sb_reg_x550(hw,
1983 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
1984 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1985 if (status != IXGBE_SUCCESS)
1987 reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
1988 status = ixgbe_write_iosf_sb_reg_x550(hw,
1989 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
1990 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1991 if (status != IXGBE_SUCCESS)
1994 /* Training bypass. */
1995 status = ixgbe_read_iosf_sb_reg_x550(hw,
1996 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1997 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1998 if (status != IXGBE_SUCCESS)
2000 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
2001 status = ixgbe_write_iosf_sb_reg_x550(hw,
2002 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2003 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2009 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2010 * assuming that the semaphore is already obtained.
2011 * @hw: pointer to hardware structure
2012 * @offset: offset of word in the EEPROM to read
2013 * @data: word read from the EEPROM
2015 * Reads a 16 bit word from the EEPROM using the hostif.
2017 s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2021 struct ixgbe_hic_read_shadow_ram buffer;
2023 DEBUGFUNC("ixgbe_read_ee_hostif_data_X550");
2024 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2025 buffer.hdr.req.buf_lenh = 0;
2026 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2027 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2029 /* convert offset from words to bytes */
2030 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2032 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2034 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2036 IXGBE_HI_COMMAND_TIMEOUT, false);
2041 *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
2042 FW_NVM_DATA_OFFSET);
2048 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2049 * @hw: pointer to hardware structure
2050 * @offset: offset of word in the EEPROM to read
2051 * @data: word read from the EEPROM
2053 * Reads a 16 bit word from the EEPROM using the hostif.
2055 s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2058 s32 status = IXGBE_SUCCESS;
2060 DEBUGFUNC("ixgbe_read_ee_hostif_X550");
2062 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2064 status = ixgbe_read_ee_hostif_data_X550(hw, offset, data);
2065 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2067 status = IXGBE_ERR_SWFW_SYNC;
2074 * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
2075 * @hw: pointer to hardware structure
2076 * @offset: offset of word in the EEPROM to read
2077 * @words: number of words
2078 * @data: word(s) read from the EEPROM
2080 * Reads a 16 bit word(s) from the EEPROM using the hostif.
2082 s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2083 u16 offset, u16 words, u16 *data)
2085 struct ixgbe_hic_read_shadow_ram buffer;
2086 u32 current_word = 0;
2091 DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
2093 /* Take semaphore for the entire operation. */
2094 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2096 DEBUGOUT("EEPROM read buffer - semaphore failed\n");
2100 if (words > FW_MAX_READ_BUFFER_SIZE / 2)
2101 words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
2103 words_to_read = words;
2105 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2106 buffer.hdr.req.buf_lenh = 0;
2107 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2108 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2110 /* convert offset from words to bytes */
2111 buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
2112 buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
2114 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2116 IXGBE_HI_COMMAND_TIMEOUT,
2120 DEBUGOUT("Host interface command failed\n");
2124 for (i = 0; i < words_to_read; i++) {
2125 u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
2127 u32 value = IXGBE_READ_REG(hw, reg);
2129 data[current_word] = (u16)(value & 0xffff);
2132 if (i < words_to_read) {
2134 data[current_word] = (u16)(value & 0xffff);
2138 words -= words_to_read;
2142 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2147 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2148 * @hw: pointer to hardware structure
2149 * @offset: offset of word in the EEPROM to write
2150 * @data: word write to the EEPROM
2152 * Write a 16 bit word to the EEPROM using the hostif.
2154 s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2158 struct ixgbe_hic_write_shadow_ram buffer;
2160 DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
2162 buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
2163 buffer.hdr.req.buf_lenh = 0;
2164 buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
2165 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2168 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2170 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2172 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2174 IXGBE_HI_COMMAND_TIMEOUT, false);
2180 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2181 * @hw: pointer to hardware structure
2182 * @offset: offset of word in the EEPROM to write
2183 * @data: word write to the EEPROM
2185 * Write a 16 bit word to the EEPROM using the hostif.
2187 s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2190 s32 status = IXGBE_SUCCESS;
2192 DEBUGFUNC("ixgbe_write_ee_hostif_X550");
2194 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2196 status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
2197 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2199 DEBUGOUT("write ee hostif failed to get semaphore");
2200 status = IXGBE_ERR_SWFW_SYNC;
2207 * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
2208 * @hw: pointer to hardware structure
2209 * @offset: offset of word in the EEPROM to write
2210 * @words: number of words
2211 * @data: word(s) write to the EEPROM
2213 * Write a 16 bit word(s) to the EEPROM using the hostif.
2215 s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2216 u16 offset, u16 words, u16 *data)
2218 s32 status = IXGBE_SUCCESS;
2221 DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
2223 /* Take semaphore for the entire operation. */
2224 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2225 if (status != IXGBE_SUCCESS) {
2226 DEBUGOUT("EEPROM write buffer - semaphore failed\n");
2230 for (i = 0; i < words; i++) {
2231 status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
2234 if (status != IXGBE_SUCCESS) {
2235 DEBUGOUT("Eeprom buffered write failed\n");
2240 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2247 * ixgbe_checksum_ptr_x550 - Checksum one pointer region
2248 * @hw: pointer to hardware structure
2249 * @ptr: pointer offset in eeprom
2250 * @size: size of section pointed by ptr, if 0 first word will be used as size
2251 * @csum: address of checksum to update
2253 * Returns error status for any failure
2255 STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
2256 u16 size, u16 *csum, u16 *buffer,
2261 u16 length, bufsz, i, start;
2264 bufsz = sizeof(buf) / sizeof(buf[0]);
2266 /* Read a chunk at the pointer location */
2268 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
2270 DEBUGOUT("Failed to read EEPROM image\n");
2275 if (buffer_size < ptr)
2276 return IXGBE_ERR_PARAM;
2277 local_buffer = &buffer[ptr];
2285 length = local_buffer[0];
2287 /* Skip pointer section if length is invalid. */
2288 if (length == 0xFFFF || length == 0 ||
2289 (ptr + length) >= hw->eeprom.word_size)
2290 return IXGBE_SUCCESS;
2293 if (buffer && ((u32)start + (u32)length > buffer_size))
2294 return IXGBE_ERR_PARAM;
2296 for (i = start; length; i++, length--) {
2297 if (i == bufsz && !buffer) {
2303 /* Read a chunk at the pointer location */
2304 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
2307 DEBUGOUT("Failed to read EEPROM image\n");
2311 *csum += local_buffer[i];
2313 return IXGBE_SUCCESS;
2317 * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
2318 * @hw: pointer to hardware structure
2319 * @buffer: pointer to buffer containing calculated checksum
2320 * @buffer_size: size of buffer
2322 * Returns a negative error code on error, or the 16-bit checksum
2324 s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
2326 u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
2330 u16 pointer, i, size;
2332 DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
2334 hw->eeprom.ops.init_params(hw);
2337 /* Read pointer area */
2338 status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
2339 IXGBE_EEPROM_LAST_WORD + 1,
2342 DEBUGOUT("Failed to read EEPROM image\n");
2345 local_buffer = eeprom_ptrs;
2347 if (buffer_size < IXGBE_EEPROM_LAST_WORD)
2348 return IXGBE_ERR_PARAM;
2349 local_buffer = buffer;
2353 * For X550 hardware include 0x0-0x41 in the checksum, skip the
2354 * checksum word itself
2356 for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
2357 if (i != IXGBE_EEPROM_CHECKSUM)
2358 checksum += local_buffer[i];
2361 * Include all data from pointers 0x3, 0x6-0xE. This excludes the
2362 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
2364 for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
2365 if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
2368 pointer = local_buffer[i];
2370 /* Skip pointer section if the pointer is invalid. */
2371 if (pointer == 0xFFFF || pointer == 0 ||
2372 pointer >= hw->eeprom.word_size)
2376 case IXGBE_PCIE_GENERAL_PTR:
2377 size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
2379 case IXGBE_PCIE_CONFIG0_PTR:
2380 case IXGBE_PCIE_CONFIG1_PTR:
2381 size = IXGBE_PCIE_CONFIG_SIZE;
2388 status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
2389 buffer, buffer_size);
2394 checksum = (u16)IXGBE_EEPROM_SUM - checksum;
2396 return (s32)checksum;
2400 * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
2401 * @hw: pointer to hardware structure
2403 * Returns a negative error code on error, or the 16-bit checksum
2405 s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
2407 return ixgbe_calc_checksum_X550(hw, NULL, 0);
2411 * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
2412 * @hw: pointer to hardware structure
2413 * @checksum_val: calculated checksum
2415 * Performs checksum calculation and validates the EEPROM checksum. If the
2416 * caller does not need checksum_val, the value can be NULL.
2418 s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
2422 u16 read_checksum = 0;
2424 DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
2426 /* Read the first word from the EEPROM. If this times out or fails, do
2427 * not continue or we could be in for a very long wait while every
2430 status = hw->eeprom.ops.read(hw, 0, &checksum);
2432 DEBUGOUT("EEPROM read failed\n");
2436 status = hw->eeprom.ops.calc_checksum(hw);
2440 checksum = (u16)(status & 0xffff);
2442 status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
2447 /* Verify read checksum from EEPROM is the same as
2448 * calculated checksum
2450 if (read_checksum != checksum) {
2451 status = IXGBE_ERR_EEPROM_CHECKSUM;
2452 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
2453 "Invalid EEPROM checksum");
2456 /* If the user cares, return the calculated checksum */
2458 *checksum_val = checksum;
2464 * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
2465 * @hw: pointer to hardware structure
2467 * After writing EEPROM to shadow RAM using EEWR register, software calculates
2468 * checksum and updates the EEPROM and instructs the hardware to update
2471 s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
2476 DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
2478 /* Read the first word from the EEPROM. If this times out or fails, do
2479 * not continue or we could be in for a very long wait while every
2482 status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
2484 DEBUGOUT("EEPROM read failed\n");
2488 status = ixgbe_calc_eeprom_checksum_X550(hw);
2492 checksum = (u16)(status & 0xffff);
2494 status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
2499 status = ixgbe_update_flash_X550(hw);
2505 * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
2506 * @hw: pointer to hardware structure
2508 * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
2510 s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
2512 s32 status = IXGBE_SUCCESS;
2513 union ixgbe_hic_hdr2 buffer;
2515 DEBUGFUNC("ixgbe_update_flash_X550");
2517 buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
2518 buffer.req.buf_lenh = 0;
2519 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
2520 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
2522 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2524 IXGBE_HI_COMMAND_TIMEOUT, false);
2530 * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
2531 * @hw: pointer to hardware structure
2533 * Determines physical layer capabilities of the current configuration.
2535 u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
2537 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
2538 u16 ext_ability = 0;
2540 DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
2542 hw->phy.ops.identify(hw);
2544 switch (hw->phy.type) {
2545 case ixgbe_phy_x550em_kr:
2546 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
2547 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2549 case ixgbe_phy_x550em_kx4:
2550 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
2551 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2553 case ixgbe_phy_x550em_ext_t:
2554 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
2555 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
2557 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
2558 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
2559 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
2560 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
2566 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
2567 physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
2569 return physical_layer;
2573 * ixgbe_get_bus_info_x550em - Set PCI bus info
2574 * @hw: pointer to hardware structure
2576 * Sets bus link width and speed to unknown because X550em is
2579 s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
2582 DEBUGFUNC("ixgbe_get_bus_info_x550em");
2584 hw->bus.width = ixgbe_bus_width_unknown;
2585 hw->bus.speed = ixgbe_bus_speed_unknown;
2587 hw->mac.ops.set_lan_id(hw);
2589 return IXGBE_SUCCESS;
2593 * ixgbe_disable_rx_x550 - Disable RX unit
2595 * Enables the Rx DMA unit for x550
2597 void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
2599 u32 rxctrl, pfdtxgswc;
2601 struct ixgbe_hic_disable_rxen fw_cmd;
2603 DEBUGFUNC("ixgbe_enable_rx_dma_x550");
2605 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
2606 if (rxctrl & IXGBE_RXCTRL_RXEN) {
2607 pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
2608 if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
2609 pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
2610 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
2611 hw->mac.set_lben = true;
2613 hw->mac.set_lben = false;
2616 fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
2617 fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
2618 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
2619 fw_cmd.port_number = (u8)hw->bus.lan_id;
2621 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
2622 sizeof(struct ixgbe_hic_disable_rxen),
2623 IXGBE_HI_COMMAND_TIMEOUT, true);
2625 /* If we fail - disable RX using register write */
2627 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
2628 if (rxctrl & IXGBE_RXCTRL_RXEN) {
2629 rxctrl &= ~IXGBE_RXCTRL_RXEN;
2630 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
2637 * ixgbe_enter_lplu_x550em - Transition to low power states
2638 * @hw: pointer to hardware structure
2640 * Configures Low Power Link Up on transition to low power states
2641 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
2642 * X557 PHY immediately prior to entering LPLU.
2644 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
2646 u16 autoneg_status, an_10g_cntl_reg, autoneg_reg, speed;
2648 ixgbe_link_speed lcd_speed;
2651 /* If blocked by MNG FW, then don't restart AN */
2652 if (ixgbe_check_reset_blocked(hw))
2653 return IXGBE_SUCCESS;
2655 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
2656 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2659 if (status != IXGBE_SUCCESS)
2662 status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
2664 if (status != IXGBE_SUCCESS)
2667 /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
2668 * disabled, then force link down by entering low power mode.
2670 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS) ||
2671 !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
2672 !(hw->wol_enabled || ixgbe_mng_present(hw)))
2673 return ixgbe_set_copper_phy_power(hw, FALSE);
2676 status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
2678 if (status != IXGBE_SUCCESS)
2681 /* If no valid LCD link speed, then force link down and exit. */
2682 if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
2683 return ixgbe_set_copper_phy_power(hw, FALSE);
2685 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
2686 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2689 if (status != IXGBE_SUCCESS)
2692 /* clear everything but the speed bits */
2693 speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
2695 /* If current speed is already LCD, then exit. */
2696 if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
2697 (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
2698 ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
2699 (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
2702 /* Clear AN completed indication */
2703 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
2704 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2707 if (status != IXGBE_SUCCESS)
2710 status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
2711 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2714 if (status != IXGBE_SUCCESS)
2717 status = hw->phy.ops.read_reg(hw,
2718 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
2719 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2722 if (status != IXGBE_SUCCESS)
2725 save_autoneg = hw->phy.autoneg_advertised;
2727 /* Setup link at least common link speed */
2728 status = hw->mac.ops.setup_link(hw, lcd_speed, false);
2730 /* restore autoneg from before setting lplu speed */
2731 hw->phy.autoneg_advertised = save_autoneg;
2737 * ixgbe_get_lcd_x550em - Determine lowest common denominator
2738 * @hw: pointer to hardware structure
2739 * @lcd_speed: pointer to lowest common link speed
2741 * Determine lowest common link speed with link partner.
2743 s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
2747 u16 word = hw->eeprom.ctrl_word_3;
2749 *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
2751 status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
2752 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2755 if (status != IXGBE_SUCCESS)
2758 /* If link partner advertised 1G, return 1G */
2759 if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
2760 *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
2764 /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
2765 if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
2766 (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
2769 /* Link partner not capable of lower speeds, return 10G */
2770 *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
2775 * ixgbe_setup_fc_X550em - Set up flow control
2776 * @hw: pointer to hardware structure
2778 * Called at init time to set up flow control.
2780 s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
2782 s32 ret_val = IXGBE_SUCCESS;
2783 u32 pause, asm_dir, reg_val;
2785 DEBUGFUNC("ixgbe_setup_fc_X550em");
2787 /* Validate the requested mode */
2788 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
2789 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
2790 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
2791 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
2795 /* 10gig parts do not have a word in the EEPROM to determine the
2796 * default flow control setting, so we explicitly set it to full.
2798 if (hw->fc.requested_mode == ixgbe_fc_default)
2799 hw->fc.requested_mode = ixgbe_fc_full;
2801 /* Determine PAUSE and ASM_DIR bits. */
2802 switch (hw->fc.requested_mode) {
2807 case ixgbe_fc_tx_pause:
2811 case ixgbe_fc_rx_pause:
2812 /* Rx Flow control is enabled and Tx Flow control is
2813 * disabled by software override. Since there really
2814 * isn't a way to advertise that we are capable of RX
2815 * Pause ONLY, we will advertise that we support both
2816 * symmetric and asymmetric Rx PAUSE, as such we fall
2817 * through to the fc_full statement. Later, we will
2818 * disable the adapter's ability to send PAUSE frames.
2825 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
2826 "Flow control param set incorrectly\n");
2827 ret_val = IXGBE_ERR_CONFIG;
2831 if (hw->phy.media_type == ixgbe_media_type_backplane) {
2832 ret_val = ixgbe_read_iosf_sb_reg_x550(hw,
2833 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
2834 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2835 if (ret_val != IXGBE_SUCCESS)
2837 reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
2838 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
2840 reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
2842 reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
2843 ret_val = ixgbe_write_iosf_sb_reg_x550(hw,
2844 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
2845 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2847 /* Not all devices fully support AN. */
2848 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR)
2849 hw->fc.disable_fc_autoneg = true;
2857 * ixgbe_set_mux - Set mux for port 1 access with CS4227
2858 * @hw: pointer to hardware structure
2859 * @state: set mux if 1, clear if 0
2861 STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
2865 if (!hw->bus.lan_id)
2867 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
2869 esdp |= IXGBE_ESDP_SDP1;
2871 esdp &= ~IXGBE_ESDP_SDP1;
2872 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
2873 IXGBE_WRITE_FLUSH(hw);
2877 * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
2878 * @hw: pointer to hardware structure
2879 * @mask: Mask to specify which semaphore to acquire
2881 * Acquires the SWFW semaphore and sets the I2C MUX
2883 s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
2887 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
2889 status = ixgbe_acquire_swfw_sync_X540(hw, mask);
2893 if (mask & IXGBE_GSSR_I2C_MASK)
2894 ixgbe_set_mux(hw, 1);
2896 return IXGBE_SUCCESS;
2900 * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
2901 * @hw: pointer to hardware structure
2902 * @mask: Mask to specify which semaphore to release
2904 * Releases the SWFW semaphore and sets the I2C MUX
2906 void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
2908 DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
2910 if (mask & IXGBE_GSSR_I2C_MASK)
2911 ixgbe_set_mux(hw, 0);
2913 ixgbe_release_swfw_sync_X540(hw, mask);
2917 * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
2918 * @hw: pointer to hardware structure
2920 * Handle external Base T PHY interrupt. If high temperature
2921 * failure alarm then return error, else if link status change
2922 * then setup internal/external PHY link
2924 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
2925 * failure alarm, else return PHY access status.
2927 s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
2932 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
2934 if (status != IXGBE_SUCCESS)
2938 return ixgbe_setup_internal_phy_t_x550em(hw);
2940 return IXGBE_SUCCESS;
2944 * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
2945 * @hw: pointer to hardware structure
2946 * @speed: new link speed
2947 * @autoneg_wait_to_complete: true when waiting for completion is needed
2949 * Setup internal/external PHY link speed based on link speed, then set
2950 * external PHY auto advertised link speed.
2952 * Returns error status for any failure
2954 s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
2955 ixgbe_link_speed speed,
2956 bool autoneg_wait_to_complete)
2959 ixgbe_link_speed force_speed;
2961 DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
2963 /* Setup internal/external PHY link speed to iXFI (10G), unless
2964 * only 1G is auto advertised then setup KX link.
2966 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
2967 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
2969 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
2971 status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
2973 if (status != IXGBE_SUCCESS)
2976 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
2980 * ixgbe_check_link_t_X550em - Determine link and speed status
2981 * @hw: pointer to hardware structure
2982 * @speed: pointer to link speed
2983 * @link_up: true when link is up
2984 * @link_up_wait_to_complete: bool used to wait for link up or not
2986 * Check that both the MAC and X557 external PHY have link.
2988 s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
2989 bool *link_up, bool link_up_wait_to_complete)
2994 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
2995 return IXGBE_ERR_CONFIG;
2997 status = ixgbe_check_mac_link_generic(hw, speed, link_up,
2998 link_up_wait_to_complete);
3000 /* If check link fails or MAC link is not up, then return */
3001 if (status != IXGBE_SUCCESS || !(*link_up))
3004 /* MAC link is up, so check external PHY link.
3005 * Read this twice back to back to indicate current status.
3007 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3008 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3011 if (status != IXGBE_SUCCESS)
3014 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3015 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3018 if (status != IXGBE_SUCCESS)
3021 /* If external PHY link is not up, then indicate link not up */
3022 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
3025 return IXGBE_SUCCESS;
3029 * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
3030 * @hw: pointer to hardware structure
3032 s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
3036 status = ixgbe_reset_phy_generic(hw);
3038 if (status != IXGBE_SUCCESS)
3041 /* Configure Link Status Alarm and Temperature Threshold interrupts */
3042 return ixgbe_enable_lasi_ext_t_x550em(hw);