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);
44 * ixgbe_init_ops_X550 - Inits func ptrs and MAC type
45 * @hw: pointer to hardware structure
47 * Initialize the function pointers and assign the MAC type for X550.
48 * Does not touch the hardware.
50 s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
52 struct ixgbe_mac_info *mac = &hw->mac;
53 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
56 DEBUGFUNC("ixgbe_init_ops_X550");
58 ret_val = ixgbe_init_ops_X540(hw);
59 mac->ops.dmac_config = ixgbe_dmac_config_X550;
60 mac->ops.dmac_config_tcs = ixgbe_dmac_config_tcs_X550;
61 mac->ops.dmac_update_tcs = ixgbe_dmac_update_tcs_X550;
62 mac->ops.setup_eee = ixgbe_setup_eee_X550;
63 mac->ops.set_source_address_pruning =
64 ixgbe_set_source_address_pruning_X550;
65 mac->ops.set_ethertype_anti_spoofing =
66 ixgbe_set_ethertype_anti_spoofing_X550;
68 mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
69 eeprom->ops.init_params = ixgbe_init_eeprom_params_X550;
70 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
71 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
72 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
73 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
74 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
75 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
76 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
78 mac->ops.disable_mdd = ixgbe_disable_mdd_X550;
79 mac->ops.enable_mdd = ixgbe_enable_mdd_X550;
80 mac->ops.mdd_event = ixgbe_mdd_event_X550;
81 mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
82 mac->ops.disable_rx = ixgbe_disable_rx_x550;
87 * ixgbe_read_cs4227 - Read CS4227 register
88 * @hw: pointer to hardware structure
89 * @reg: register number to write
90 * @value: pointer to receive value read
94 STATIC s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
96 return ixgbe_read_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
100 * ixgbe_write_cs4227 - Write CS4227 register
101 * @hw: pointer to hardware structure
102 * @reg: register number to write
103 * @value: value to write to register
105 * Returns status code
107 STATIC s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
109 return ixgbe_write_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
113 * ixgbe_get_cs4227_status - Return CS4227 status
114 * @hw: pointer to hardware structure
116 * Returns error if CS4227 not successfully initialized
118 STATIC s32 ixgbe_get_cs4227_status(struct ixgbe_hw *hw)
122 u16 reg_slice, reg_val;
125 for (retry = 0; retry < IXGBE_CS4227_RETRIES; ++retry) {
126 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_GLOBAL_ID_LSB,
128 if (status != IXGBE_SUCCESS)
130 if (value == IXGBE_CS4227_GLOBAL_ID_VALUE)
132 msec_delay(IXGBE_CS4227_CHECK_DELAY);
134 if (value != IXGBE_CS4227_GLOBAL_ID_VALUE)
135 return IXGBE_ERR_PHY;
137 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
138 if (status != IXGBE_SUCCESS)
141 /* If this is the first time after power-on, check the ucode.
142 * Otherwise, this will disrupt link on all ports. Because we
143 * can only do this the first time, we must check all ports,
146 if (value != IXGBE_CS4227_SCRATCH_VALUE) {
147 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
148 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
149 status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
150 if (status != IXGBE_SUCCESS)
153 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB;
154 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
155 status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
156 if (status != IXGBE_SUCCESS)
159 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
160 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
161 status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
162 if (status != IXGBE_SUCCESS)
165 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (1 << 12);
166 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
167 status = ixgbe_write_cs4227(hw, reg_slice, reg_val);
168 if (status != IXGBE_SUCCESS)
174 /* Verify that the ucode is operational on all ports. */
175 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
177 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
178 if (status != IXGBE_SUCCESS)
181 return IXGBE_ERR_PHY;
183 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB;
185 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
186 if (status != IXGBE_SUCCESS)
189 return IXGBE_ERR_PHY;
191 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
193 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
194 if (status != IXGBE_SUCCESS)
197 return IXGBE_ERR_PHY;
199 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (1 << 12);
201 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
202 if (status != IXGBE_SUCCESS)
205 return IXGBE_ERR_PHY;
207 /* Set scratch indicating that the diagnostic was successful. */
208 status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
209 IXGBE_CS4227_SCRATCH_VALUE);
210 if (status != IXGBE_SUCCESS)
212 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
213 if (status != IXGBE_SUCCESS)
215 if (value != IXGBE_CS4227_SCRATCH_VALUE)
216 return IXGBE_ERR_PHY;
218 return IXGBE_SUCCESS;
222 * ixgbe_read_pe - Read register from port expander
223 * @hw: pointer to hardware structure
224 * @reg: register number to read
225 * @value: pointer to receive read value
227 * Returns status code
229 STATIC s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
233 status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
234 if (status != IXGBE_SUCCESS)
235 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
236 "port expander access failed with %d\n", status);
241 * ixgbe_write_pe - Write register to port expander
242 * @hw: pointer to hardware structure
243 * @reg: register number to write
244 * @value: value to write
246 * Returns status code
248 STATIC s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
252 status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
253 if (status != IXGBE_SUCCESS)
254 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
255 "port expander access failed with %d\n", status);
260 * ixgbe_reset_cs4227 - Reset CS4227 using port expander
261 * @hw: pointer to hardware structure
265 STATIC s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
270 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
271 if (status != IXGBE_SUCCESS)
273 reg |= IXGBE_PE_BIT1;
274 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
275 if (status != IXGBE_SUCCESS)
278 status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, ®);
279 if (status != IXGBE_SUCCESS)
281 reg &= ~IXGBE_PE_BIT1;
282 status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
283 if (status != IXGBE_SUCCESS)
286 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
287 if (status != IXGBE_SUCCESS)
289 reg &= ~IXGBE_PE_BIT1;
290 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
291 if (status != IXGBE_SUCCESS)
294 usec_delay(IXGBE_CS4227_RESET_HOLD);
296 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
297 if (status != IXGBE_SUCCESS)
299 reg |= IXGBE_PE_BIT1;
300 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
301 if (status != IXGBE_SUCCESS)
304 msec_delay(IXGBE_CS4227_RESET_DELAY);
306 return IXGBE_SUCCESS;
310 * ixgbe_check_cs4227 - Check CS4227 and reset as needed
311 * @hw: pointer to hardware structure
313 STATIC void ixgbe_check_cs4227(struct ixgbe_hw *hw)
315 u32 swfw_mask = hw->phy.phy_semaphore_mask;
319 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
320 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
321 if (status != IXGBE_SUCCESS) {
322 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
323 "semaphore failed with %d\n", status);
326 status = ixgbe_get_cs4227_status(hw);
327 if (status == IXGBE_SUCCESS) {
328 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
329 msec_delay(hw->eeprom.semaphore_delay);
332 ixgbe_reset_cs4227(hw);
333 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
334 msec_delay(hw->eeprom.semaphore_delay);
336 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
337 "Unable to initialize CS4227, err=%d\n", status);
341 * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
342 * @hw: pointer to hardware structure
344 STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
346 u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
348 if (hw->bus.lan_id) {
349 esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
350 esdp |= IXGBE_ESDP_SDP1_DIR;
352 esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
353 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
354 IXGBE_WRITE_FLUSH(hw);
358 * ixgbe_identify_phy_x550em - Get PHY type based on device id
359 * @hw: pointer to hardware structure
363 STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
365 switch (hw->device_id) {
366 case IXGBE_DEV_ID_X550EM_X_SFP:
367 /* set up for CS4227 usage */
368 hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
369 ixgbe_setup_mux_ctl(hw);
370 ixgbe_check_cs4227(hw);
372 return ixgbe_identify_module_generic(hw);
374 case IXGBE_DEV_ID_X550EM_X_KX4:
375 hw->phy.type = ixgbe_phy_x550em_kx4;
377 case IXGBE_DEV_ID_X550EM_X_KR:
378 hw->phy.type = ixgbe_phy_x550em_kr;
380 case IXGBE_DEV_ID_X550EM_X_1G_T:
381 case IXGBE_DEV_ID_X550EM_X_10G_T:
382 return ixgbe_identify_phy_generic(hw);
386 return IXGBE_SUCCESS;
389 STATIC s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
390 u32 device_type, u16 *phy_data)
392 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
393 return IXGBE_NOT_IMPLEMENTED;
396 STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
397 u32 device_type, u16 phy_data)
399 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
400 return IXGBE_NOT_IMPLEMENTED;
404 * ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
405 * @hw: pointer to hardware structure
407 * Initialize the function pointers and for MAC type X550EM.
408 * Does not touch the hardware.
410 s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
412 struct ixgbe_mac_info *mac = &hw->mac;
413 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
414 struct ixgbe_phy_info *phy = &hw->phy;
417 DEBUGFUNC("ixgbe_init_ops_X550EM");
419 /* Similar to X550 so start there. */
420 ret_val = ixgbe_init_ops_X550(hw);
422 /* Since this function eventually calls
423 * ixgbe_init_ops_540 by design, we are setting
424 * the pointers to NULL explicitly here to overwrite
425 * the values being set in the x540 function.
427 /* Thermal sensor not supported in x550EM */
428 mac->ops.get_thermal_sensor_data = NULL;
429 mac->ops.init_thermal_sensor_thresh = NULL;
430 mac->thermal_sensor_enabled = false;
432 /* FCOE not supported in x550EM */
433 mac->ops.get_san_mac_addr = NULL;
434 mac->ops.set_san_mac_addr = NULL;
435 mac->ops.get_wwn_prefix = NULL;
436 mac->ops.get_fcoe_boot_status = NULL;
438 /* IPsec not supported in x550EM */
439 mac->ops.disable_sec_rx_path = NULL;
440 mac->ops.enable_sec_rx_path = NULL;
442 /* AUTOC register is not present in x550EM. */
443 mac->ops.prot_autoc_read = NULL;
444 mac->ops.prot_autoc_write = NULL;
446 /* X550EM bus type is internal*/
447 hw->bus.type = ixgbe_bus_type_internal;
448 mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
450 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
451 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
452 mac->ops.get_media_type = ixgbe_get_media_type_X550em;
453 mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
454 mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
455 mac->ops.reset_hw = ixgbe_reset_hw_X550em;
456 mac->ops.get_supported_physical_layer =
457 ixgbe_get_supported_physical_layer_X550em;
459 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
460 mac->ops.setup_fc = ixgbe_setup_fc_generic;
462 mac->ops.setup_fc = ixgbe_setup_fc_X550em;
464 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
465 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
467 if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
468 mac->ops.setup_eee = NULL;
471 phy->ops.init = ixgbe_init_phy_ops_X550em;
472 phy->ops.identify = ixgbe_identify_phy_x550em;
473 if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
474 phy->ops.set_phy_power = NULL;
478 eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
479 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
480 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
481 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
482 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
483 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
484 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
485 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
491 * ixgbe_dmac_config_X550
492 * @hw: pointer to hardware structure
494 * Configure DMA coalescing. If enabling dmac, dmac is activated.
495 * When disabling dmac, dmac enable dmac bit is cleared.
497 s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
499 u32 reg, high_pri_tc;
501 DEBUGFUNC("ixgbe_dmac_config_X550");
503 /* Disable DMA coalescing before configuring */
504 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
505 reg &= ~IXGBE_DMACR_DMAC_EN;
506 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
508 /* Disable DMA Coalescing if the watchdog timer is 0 */
509 if (!hw->mac.dmac_config.watchdog_timer)
512 ixgbe_dmac_config_tcs_X550(hw);
514 /* Configure DMA Coalescing Control Register */
515 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
517 /* Set the watchdog timer in units of 40.96 usec */
518 reg &= ~IXGBE_DMACR_DMACWT_MASK;
519 reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
521 reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
522 /* If fcoe is enabled, set high priority traffic class */
523 if (hw->mac.dmac_config.fcoe_en) {
524 high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
525 reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
526 IXGBE_DMACR_HIGH_PRI_TC_MASK);
528 reg |= IXGBE_DMACR_EN_MNG_IND;
530 /* Enable DMA coalescing after configuration */
531 reg |= IXGBE_DMACR_DMAC_EN;
532 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
535 return IXGBE_SUCCESS;
539 * ixgbe_dmac_config_tcs_X550
540 * @hw: pointer to hardware structure
542 * Configure DMA coalescing threshold per TC. The dmac enable bit must
543 * be cleared before configuring.
545 s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
547 u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
549 DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
551 /* Configure DMA coalescing enabled */
552 switch (hw->mac.dmac_config.link_speed) {
553 case IXGBE_LINK_SPEED_100_FULL:
554 pb_headroom = IXGBE_DMACRXT_100M;
556 case IXGBE_LINK_SPEED_1GB_FULL:
557 pb_headroom = IXGBE_DMACRXT_1G;
560 pb_headroom = IXGBE_DMACRXT_10G;
564 maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
565 IXGBE_MHADD_MFS_SHIFT) / 1024);
567 /* Set the per Rx packet buffer receive threshold */
568 for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
569 reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
570 reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
572 if (tc < hw->mac.dmac_config.num_tcs) {
574 rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
575 rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
576 IXGBE_RXPBSIZE_SHIFT;
578 /* Calculate receive buffer threshold in kilobytes */
579 if (rx_pb_size > pb_headroom)
580 rx_pb_size = rx_pb_size - pb_headroom;
584 /* Minimum of MFS shall be set for DMCTH */
585 reg |= (rx_pb_size > maxframe_size_kb) ?
586 rx_pb_size : maxframe_size_kb;
588 IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
590 return IXGBE_SUCCESS;
594 * ixgbe_dmac_update_tcs_X550
595 * @hw: pointer to hardware structure
597 * Disables dmac, updates per TC settings, and then enables dmac.
599 s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
603 DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
605 /* Disable DMA coalescing before configuring */
606 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
607 reg &= ~IXGBE_DMACR_DMAC_EN;
608 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
610 ixgbe_dmac_config_tcs_X550(hw);
612 /* Enable DMA coalescing after configuration */
613 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
614 reg |= IXGBE_DMACR_DMAC_EN;
615 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
617 return IXGBE_SUCCESS;
621 * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
622 * @hw: pointer to hardware structure
624 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
625 * ixgbe_hw struct in order to set up EEPROM access.
627 s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
629 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
633 DEBUGFUNC("ixgbe_init_eeprom_params_X550");
635 if (eeprom->type == ixgbe_eeprom_uninitialized) {
636 eeprom->semaphore_delay = 10;
637 eeprom->type = ixgbe_flash;
639 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
640 eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
641 IXGBE_EEC_SIZE_SHIFT);
642 eeprom->word_size = 1 << (eeprom_size +
643 IXGBE_EEPROM_WORD_SIZE_SHIFT);
645 DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
646 eeprom->type, eeprom->word_size);
649 return IXGBE_SUCCESS;
653 * ixgbe_setup_eee_X550 - Enable/disable EEE support
654 * @hw: pointer to the HW structure
655 * @enable_eee: boolean flag to enable EEE
657 * Enable/disable EEE based on enable_eee flag.
658 * Auto-negotiation must be started after BASE-T EEE bits in PHY register 7.3C
662 s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
670 DEBUGFUNC("ixgbe_setup_eee_X550");
672 eeer = IXGBE_READ_REG(hw, IXGBE_EEER);
673 /* Enable or disable EEE per flag */
675 eeer |= (IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
677 if (hw->device_id == IXGBE_DEV_ID_X550T) {
678 /* Advertise EEE capability */
679 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
680 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
682 autoneg_eee_reg |= (IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
683 IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
684 IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
686 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
687 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
688 } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
689 /* Not supported on first revision. */
690 fuse = IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0));
691 if (!(fuse & IXGBE_FUSES0_REV1))
692 return IXGBE_SUCCESS;
694 status = ixgbe_read_iosf_sb_reg_x550(hw,
695 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
696 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
697 if (status != IXGBE_SUCCESS)
700 link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
701 IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;
703 /* Don't advertise FEC capability when EEE enabled. */
704 link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
706 status = ixgbe_write_iosf_sb_reg_x550(hw,
707 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
708 IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
709 if (status != IXGBE_SUCCESS)
713 eeer &= ~(IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
715 if (hw->device_id == IXGBE_DEV_ID_X550T) {
716 /* Disable advertised EEE capability */
717 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
718 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
720 autoneg_eee_reg &= ~(IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
721 IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
722 IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
724 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
725 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
726 } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
727 status = ixgbe_read_iosf_sb_reg_x550(hw,
728 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
729 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
730 if (status != IXGBE_SUCCESS)
733 link_reg &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
734 IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX);
736 /* Advertise FEC capability when EEE is disabled. */
737 link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
739 status = ixgbe_write_iosf_sb_reg_x550(hw,
740 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
741 IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
742 if (status != IXGBE_SUCCESS)
746 IXGBE_WRITE_REG(hw, IXGBE_EEER, eeer);
748 return IXGBE_SUCCESS;
752 * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
753 * @hw: pointer to hardware structure
754 * @enable: enable or disable source address pruning
755 * @pool: Rx pool to set source address pruning for
757 void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
762 /* max rx pool is 63 */
766 pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
767 pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
770 pfflp |= (1ULL << pool);
772 pfflp &= ~(1ULL << pool);
774 IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
775 IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
779 * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
780 * @hw: pointer to hardware structure
781 * @enable: enable or disable switch for Ethertype anti-spoofing
782 * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
785 void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
788 int vf_target_reg = vf >> 3;
789 int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
792 DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
794 pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
796 pfvfspoof |= (1 << vf_target_shift);
798 pfvfspoof &= ~(1 << vf_target_shift);
800 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
804 * ixgbe_iosf_wait - Wait for IOSF command completion
805 * @hw: pointer to hardware structure
806 * @ctrl: pointer to location to receive final IOSF control value
808 * Returns failing status on timeout
810 * Note: ctrl can be NULL if the IOSF control register value is not needed
812 STATIC s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
816 /* Check every 10 usec to see if the address cycle completed.
817 * The SB IOSF BUSY bit will clear when the operation is
820 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
821 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
822 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
828 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
829 ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
830 return IXGBE_ERR_PHY;
833 return IXGBE_SUCCESS;
837 * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
839 * @hw: pointer to hardware structure
840 * @reg_addr: 32 bit PHY register to write
841 * @device_type: 3 bit device type
842 * @data: Data to write to the register
844 s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
845 u32 device_type, u32 data)
847 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
851 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
852 if (ret != IXGBE_SUCCESS)
855 ret = ixgbe_iosf_wait(hw, NULL);
856 if (ret != IXGBE_SUCCESS)
859 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
860 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
862 /* Write IOSF control register */
863 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
865 /* Write IOSF data register */
866 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
868 ret = ixgbe_iosf_wait(hw, &command);
870 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
871 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
872 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
873 ERROR_REPORT2(IXGBE_ERROR_POLLING,
874 "Failed to write, error %x\n", error);
879 ixgbe_release_swfw_semaphore(hw, gssr);
884 * ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
886 * @hw: pointer to hardware structure
887 * @reg_addr: 32 bit PHY register to write
888 * @device_type: 3 bit device type
889 * @phy_data: Pointer to read data from the register
891 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
892 u32 device_type, u32 *data)
894 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
898 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
899 if (ret != IXGBE_SUCCESS)
902 ret = ixgbe_iosf_wait(hw, NULL);
903 if (ret != IXGBE_SUCCESS)
906 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
907 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
909 /* Write IOSF control register */
910 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
912 ret = ixgbe_iosf_wait(hw, &command);
914 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
915 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
916 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
917 ERROR_REPORT2(IXGBE_ERROR_POLLING,
918 "Failed to read, error %x\n", error);
922 if (ret == IXGBE_SUCCESS)
923 *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
926 ixgbe_release_swfw_semaphore(hw, gssr);
931 * ixgbe_disable_mdd_X550
932 * @hw: pointer to hardware structure
934 * Disable malicious driver detection
936 void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
940 DEBUGFUNC("ixgbe_disable_mdd_X550");
942 /* Disable MDD for TX DMA and interrupt */
943 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
944 reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
945 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
947 /* Disable MDD for RX and interrupt */
948 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
949 reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
950 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
954 * ixgbe_enable_mdd_X550
955 * @hw: pointer to hardware structure
957 * Enable malicious driver detection
959 void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
963 DEBUGFUNC("ixgbe_enable_mdd_X550");
965 /* Enable MDD for TX DMA and interrupt */
966 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
967 reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
968 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
970 /* Enable MDD for RX and interrupt */
971 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
972 reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
973 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
977 * ixgbe_restore_mdd_vf_X550
978 * @hw: pointer to hardware structure
981 * Restore VF that was disabled during malicious driver detection event
983 void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
985 u32 idx, reg, num_qs, start_q, bitmask;
987 DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
989 /* Map VF to queues */
990 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
991 switch (reg & IXGBE_MRQC_MRQE_MASK) {
992 case IXGBE_MRQC_VMDQRT8TCEN:
993 num_qs = 8; /* 16 VFs / pools */
994 bitmask = 0x000000FF;
996 case IXGBE_MRQC_VMDQRSS32EN:
997 case IXGBE_MRQC_VMDQRT4TCEN:
998 num_qs = 4; /* 32 VFs / pools */
999 bitmask = 0x0000000F;
1001 default: /* 64 VFs / pools */
1003 bitmask = 0x00000003;
1006 start_q = vf * num_qs;
1008 /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
1011 reg |= (bitmask << (start_q % 32));
1012 IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
1013 IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
1017 * ixgbe_mdd_event_X550
1018 * @hw: pointer to hardware structure
1019 * @vf_bitmap: vf bitmap of malicious vfs
1021 * Handle malicious driver detection event.
1023 void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
1026 u32 i, j, reg, q, shift, vf, idx;
1028 DEBUGFUNC("ixgbe_mdd_event_X550");
1030 /* figure out pool size for mapping to vf's */
1031 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1032 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1033 case IXGBE_MRQC_VMDQRT8TCEN:
1034 shift = 3; /* 16 VFs / pools */
1036 case IXGBE_MRQC_VMDQRSS32EN:
1037 case IXGBE_MRQC_VMDQRT4TCEN:
1038 shift = 2; /* 32 VFs / pools */
1041 shift = 1; /* 64 VFs / pools */
1045 /* Read WQBR_TX and WQBR_RX and check for malicious queues */
1046 for (i = 0; i < 4; i++) {
1047 wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
1048 wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
1053 /* Get malicious queue */
1054 for (j = 0; j < 32 && wqbr; j++) {
1056 if (!(wqbr & (1 << j)))
1059 /* Get queue from bitmask */
1062 /* Map queue to vf */
1065 /* Set vf bit in vf_bitmap */
1067 vf_bitmap[idx] |= (1 << (vf % 32));
1074 * ixgbe_get_media_type_X550em - Get media type
1075 * @hw: pointer to hardware structure
1077 * Returns the media type (fiber, copper, backplane)
1079 enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1081 enum ixgbe_media_type media_type;
1083 DEBUGFUNC("ixgbe_get_media_type_X550em");
1085 /* Detect if there is a copper PHY attached. */
1086 switch (hw->device_id) {
1087 case IXGBE_DEV_ID_X550EM_X_KR:
1088 case IXGBE_DEV_ID_X550EM_X_KX4:
1089 media_type = ixgbe_media_type_backplane;
1091 case IXGBE_DEV_ID_X550EM_X_SFP:
1092 media_type = ixgbe_media_type_fiber;
1094 case IXGBE_DEV_ID_X550EM_X_1G_T:
1095 case IXGBE_DEV_ID_X550EM_X_10G_T:
1096 media_type = ixgbe_media_type_copper;
1099 media_type = ixgbe_media_type_unknown;
1106 * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
1107 * @hw: pointer to hardware structure
1108 * @linear: true if SFP module is linear
1110 STATIC s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
1112 DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
1114 switch (hw->phy.sfp_type) {
1115 case ixgbe_sfp_type_not_present:
1116 return IXGBE_ERR_SFP_NOT_PRESENT;
1117 case ixgbe_sfp_type_da_cu_core0:
1118 case ixgbe_sfp_type_da_cu_core1:
1121 case ixgbe_sfp_type_srlr_core0:
1122 case ixgbe_sfp_type_srlr_core1:
1123 case ixgbe_sfp_type_da_act_lmt_core0:
1124 case ixgbe_sfp_type_da_act_lmt_core1:
1125 case ixgbe_sfp_type_1g_sx_core0:
1126 case ixgbe_sfp_type_1g_sx_core1:
1127 case ixgbe_sfp_type_1g_lx_core0:
1128 case ixgbe_sfp_type_1g_lx_core1:
1131 case ixgbe_sfp_type_unknown:
1132 case ixgbe_sfp_type_1g_cu_core0:
1133 case ixgbe_sfp_type_1g_cu_core1:
1135 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1138 return IXGBE_SUCCESS;
1142 * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
1143 * @hw: pointer to hardware structure
1145 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1147 s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
1152 DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
1154 status = ixgbe_identify_module_generic(hw);
1156 if (status != IXGBE_SUCCESS)
1159 /* Check if SFP module is supported */
1160 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1166 * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
1167 * @hw: pointer to hardware structure
1169 s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
1174 DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
1176 /* Check if SFP module is supported */
1177 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1179 if (status != IXGBE_SUCCESS)
1182 ixgbe_init_mac_link_ops_X550em(hw);
1183 hw->phy.ops.reset = NULL;
1185 return IXGBE_SUCCESS;
1189 * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
1190 * @hw: pointer to hardware structure
1192 void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
1194 struct ixgbe_mac_info *mac = &hw->mac;
1196 DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
1198 switch (hw->mac.ops.get_media_type(hw)) {
1199 case ixgbe_media_type_fiber:
1200 /* CS4227 does not support autoneg, so disable the laser control
1201 * functions for SFP+ fiber
1203 mac->ops.disable_tx_laser = NULL;
1204 mac->ops.enable_tx_laser = NULL;
1205 mac->ops.flap_tx_laser = NULL;
1206 mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
1207 mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_x550em;
1208 mac->ops.set_rate_select_speed =
1209 ixgbe_set_soft_rate_select_speed;
1211 case ixgbe_media_type_copper:
1212 mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
1213 mac->ops.check_link = ixgbe_check_link_t_X550em;
1221 * ixgbe_get_link_capabilities_x550em - Determines link capabilities
1222 * @hw: pointer to hardware structure
1223 * @speed: pointer to link speed
1224 * @autoneg: true when autoneg or autotry is enabled
1226 s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
1227 ixgbe_link_speed *speed,
1230 DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
1233 if (hw->phy.media_type == ixgbe_media_type_fiber) {
1235 /* CS4227 SFP must not enable auto-negotiation */
1238 /* Check if 1G SFP module. */
1239 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1240 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
1241 || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1242 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
1243 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1244 return IXGBE_SUCCESS;
1247 /* Link capabilities are based on SFP */
1248 if (hw->phy.multispeed_fiber)
1249 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1250 IXGBE_LINK_SPEED_1GB_FULL;
1252 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1254 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1255 IXGBE_LINK_SPEED_1GB_FULL;
1259 return IXGBE_SUCCESS;
1263 * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
1264 * @hw: pointer to hardware structure
1265 * @lsc: pointer to boolean flag which indicates whether external Base T
1266 * PHY interrupt is lsc
1268 * Determime if external Base T PHY interrupt cause is high temperature
1269 * failure alarm or link status change.
1271 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
1272 * failure alarm, else return PHY access status.
1274 STATIC s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
1281 /* Vendor alarm triggered */
1282 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1283 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1286 if (status != IXGBE_SUCCESS ||
1287 !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
1290 /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
1291 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
1292 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1295 if (status != IXGBE_SUCCESS ||
1296 !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1297 IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
1300 /* High temperature failure alarm triggered */
1301 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
1302 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1305 if (status != IXGBE_SUCCESS)
1308 /* If high temperature failure, then return over temp error and exit */
1309 if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
1310 /* power down the PHY in case the PHY FW didn't already */
1311 ixgbe_set_copper_phy_power(hw, false);
1312 return IXGBE_ERR_OVERTEMP;
1315 /* Vendor alarm 2 triggered */
1316 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1317 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1319 if (status != IXGBE_SUCCESS ||
1320 !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
1323 /* link connect/disconnect event occurred */
1324 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
1325 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1327 if (status != IXGBE_SUCCESS)
1331 if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
1334 return IXGBE_SUCCESS;
1338 * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
1339 * @hw: pointer to hardware structure
1341 * Enable link status change and temperature failure alarm for the external
1344 * Returns PHY access status
1346 STATIC s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
1352 /* Clear interrupt flags */
1353 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
1355 /* Enable link status change alarm */
1356 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1357 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1359 if (status != IXGBE_SUCCESS)
1362 reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
1364 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1365 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
1367 if (status != IXGBE_SUCCESS)
1370 /* Enables high temperature failure alarm */
1371 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1372 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1375 if (status != IXGBE_SUCCESS)
1378 reg |= IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN;
1380 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1381 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1384 if (status != IXGBE_SUCCESS)
1387 /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
1388 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1389 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1392 if (status != IXGBE_SUCCESS)
1395 reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1396 IXGBE_MDIO_GLOBAL_ALARM_1_INT);
1398 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1399 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1402 if (status != IXGBE_SUCCESS)
1405 /* Enable chip-wide vendor alarm */
1406 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1407 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1410 if (status != IXGBE_SUCCESS)
1413 reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
1415 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1416 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1423 * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
1424 * @hw: pointer to hardware structure
1425 * @speed: link speed
1427 * Configures the integrated KR PHY.
1429 STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
1430 ixgbe_link_speed speed)
1435 status = ixgbe_read_iosf_sb_reg_x550(hw,
1436 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1437 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1441 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1442 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
1443 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
1445 /* Advertise 10G support. */
1446 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
1447 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
1449 /* Advertise 1G support. */
1450 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
1451 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
1453 /* Restart auto-negotiation. */
1454 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1455 status = ixgbe_write_iosf_sb_reg_x550(hw,
1456 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1457 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1463 * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
1464 * @hw: pointer to hardware structure
1466 * Initialize any function pointers that were not able to be
1467 * set during init_shared_code because the PHY/SFP type was
1468 * not known. Perform the SFP init if necessary.
1470 s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
1472 struct ixgbe_phy_info *phy = &hw->phy;
1473 ixgbe_link_speed speed;
1476 DEBUGFUNC("ixgbe_init_phy_ops_X550em");
1478 hw->mac.ops.set_lan_id(hw);
1480 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
1481 phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
1482 ixgbe_setup_mux_ctl(hw);
1484 /* Save NW management interface connected on board. This is used
1485 * to determine internal PHY mode.
1487 phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
1489 /* If internal PHY mode is KR, then initialize KR link */
1490 if (phy->nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE) {
1491 speed = IXGBE_LINK_SPEED_10GB_FULL |
1492 IXGBE_LINK_SPEED_1GB_FULL;
1493 ret_val = ixgbe_setup_kr_speed_x550em(hw, speed);
1496 phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
1499 /* Identify the PHY or SFP module */
1500 ret_val = phy->ops.identify(hw);
1501 if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED)
1504 /* Setup function pointers based on detected hardware */
1505 ixgbe_init_mac_link_ops_X550em(hw);
1506 if (phy->sfp_type != ixgbe_sfp_type_unknown)
1507 phy->ops.reset = NULL;
1509 /* Set functions pointers based on phy type */
1510 switch (hw->phy.type) {
1511 case ixgbe_phy_x550em_kx4:
1512 phy->ops.setup_link = ixgbe_setup_kx4_x550em;
1513 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1514 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1516 case ixgbe_phy_x550em_kr:
1517 phy->ops.setup_link = ixgbe_setup_kr_x550em;
1518 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1519 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1521 case ixgbe_phy_x550em_ext_t:
1522 /* Save NW management interface connected on board. This is used
1523 * to determine internal PHY mode
1525 phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
1527 /* If internal link mode is XFI, then setup iXFI internal link,
1528 * else setup KR now.
1530 if (!(phy->nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
1531 phy->ops.setup_internal_link =
1532 ixgbe_setup_internal_phy_t_x550em;
1534 speed = IXGBE_LINK_SPEED_10GB_FULL |
1535 IXGBE_LINK_SPEED_1GB_FULL;
1536 ret_val = ixgbe_setup_kr_speed_x550em(hw, speed);
1539 phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
1540 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
1541 phy->ops.reset = ixgbe_reset_phy_t_X550em;
1550 * ixgbe_reset_hw_X550em - Perform hardware reset
1551 * @hw: pointer to hardware structure
1553 * Resets the hardware by resetting the transmit and receive units, masks
1554 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
1557 s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
1559 ixgbe_link_speed link_speed;
1564 bool link_up = false;
1566 DEBUGFUNC("ixgbe_reset_hw_X550em");
1568 /* Call adapter stop to disable Tx/Rx and clear interrupts */
1569 status = hw->mac.ops.stop_adapter(hw);
1570 if (status != IXGBE_SUCCESS)
1573 /* flush pending Tx transactions */
1574 ixgbe_clear_tx_pending(hw);
1576 /* PHY ops must be identified and initialized prior to reset */
1578 /* Identify PHY and related function pointers */
1579 status = hw->phy.ops.init(hw);
1581 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1584 /* start the external PHY */
1585 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
1586 status = ixgbe_init_ext_t_x550em(hw);
1591 /* Setup SFP module if there is one present. */
1592 if (hw->phy.sfp_setup_needed) {
1593 status = hw->mac.ops.setup_sfp(hw);
1594 hw->phy.sfp_setup_needed = false;
1597 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1601 if (!hw->phy.reset_disable && hw->phy.ops.reset)
1602 hw->phy.ops.reset(hw);
1605 /* Issue global reset to the MAC. Needs to be SW reset if link is up.
1606 * If link reset is used when link is up, it might reset the PHY when
1607 * mng is using it. If link is down or the flag to force full link
1608 * reset is set, then perform link reset.
1610 ctrl = IXGBE_CTRL_LNK_RST;
1611 if (!hw->force_full_reset) {
1612 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
1614 ctrl = IXGBE_CTRL_RST;
1617 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
1618 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
1619 IXGBE_WRITE_FLUSH(hw);
1621 /* Poll for reset bit to self-clear meaning reset is complete */
1622 for (i = 0; i < 10; i++) {
1624 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
1625 if (!(ctrl & IXGBE_CTRL_RST_MASK))
1629 if (ctrl & IXGBE_CTRL_RST_MASK) {
1630 status = IXGBE_ERR_RESET_FAILED;
1631 DEBUGOUT("Reset polling failed to complete.\n");
1636 /* Double resets are required for recovery from certain error
1637 * conditions. Between resets, it is necessary to stall to
1638 * allow time for any pending HW events to complete.
1640 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
1641 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
1645 /* Store the permanent mac address */
1646 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
1648 /* Store MAC address from RAR0, clear receive address registers, and
1649 * clear the multicast table. Also reset num_rar_entries to 128,
1650 * since we modify this value when programming the SAN MAC address.
1652 hw->mac.num_rar_entries = 128;
1653 hw->mac.ops.init_rx_addrs(hw);
1655 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
1656 /* Config MDIO clock speed. */
1657 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
1658 hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
1659 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
1662 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
1663 ixgbe_setup_mux_ctl(hw);
1669 * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
1670 * @hw: pointer to hardware structure
1672 s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
1677 status = hw->phy.ops.read_reg(hw,
1678 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
1679 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1682 if (status != IXGBE_SUCCESS)
1685 /* If PHY FW reset completed bit is set then this is the first
1686 * SW instance after a power on so the PHY FW must be un-stalled.
1688 if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
1689 status = hw->phy.ops.read_reg(hw,
1690 IXGBE_MDIO_GLOBAL_RES_PR_10,
1691 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1694 if (status != IXGBE_SUCCESS)
1697 reg &= ~IXGBE_MDIO_POWER_UP_STALL;
1699 status = hw->phy.ops.write_reg(hw,
1700 IXGBE_MDIO_GLOBAL_RES_PR_10,
1701 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1704 if (status != IXGBE_SUCCESS)
1712 * ixgbe_setup_kr_x550em - Configure the KR PHY.
1713 * @hw: pointer to hardware structure
1715 * Configures the integrated KR PHY.
1717 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
1719 return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
1723 * ixgbe_setup_kx4_x550em - Configure the KX4 PHY.
1724 * @hw: pointer to hardware structure
1726 * Configures the integrated KX4 PHY.
1728 s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw)
1733 status = ixgbe_read_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
1734 IXGBE_SB_IOSF_TARGET_KX4_PCS, ®_val);
1738 reg_val &= ~(IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4 |
1739 IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX);
1741 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_ENABLE;
1743 /* Advertise 10G support. */
1744 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1745 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4;
1747 /* Advertise 1G support. */
1748 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1749 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX;
1751 /* Restart auto-negotiation. */
1752 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_RESTART;
1753 status = ixgbe_write_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
1754 IXGBE_SB_IOSF_TARGET_KX4_PCS, reg_val);
1760 * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
1761 * @hw: pointer to hardware structure
1762 * @speed: the link speed to force
1764 * Configures the integrated KR PHY to use iXFI mode. Used to connect an
1765 * internal and external PHY at a specific speed, without autonegotiation.
1767 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
1772 /* Disable AN and force speed to 10G Serial. */
1773 status = ixgbe_read_iosf_sb_reg_x550(hw,
1774 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1775 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1776 if (status != IXGBE_SUCCESS)
1779 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1780 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1782 /* Select forced link speed for internal PHY. */
1784 case IXGBE_LINK_SPEED_10GB_FULL:
1785 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
1787 case IXGBE_LINK_SPEED_1GB_FULL:
1788 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1791 /* Other link speeds are not supported by internal KR PHY. */
1792 return IXGBE_ERR_LINK_SETUP;
1795 status = ixgbe_write_iosf_sb_reg_x550(hw,
1796 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1797 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1798 if (status != IXGBE_SUCCESS)
1801 /* Disable training protocol FSM. */
1802 status = ixgbe_read_iosf_sb_reg_x550(hw,
1803 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1804 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1805 if (status != IXGBE_SUCCESS)
1807 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
1808 status = ixgbe_write_iosf_sb_reg_x550(hw,
1809 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1810 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1811 if (status != IXGBE_SUCCESS)
1814 /* Disable Flex from training TXFFE. */
1815 status = ixgbe_read_iosf_sb_reg_x550(hw,
1816 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
1817 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1818 if (status != IXGBE_SUCCESS)
1820 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
1821 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
1822 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
1823 status = ixgbe_write_iosf_sb_reg_x550(hw,
1824 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
1825 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1826 if (status != IXGBE_SUCCESS)
1828 status = ixgbe_read_iosf_sb_reg_x550(hw,
1829 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
1830 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1831 if (status != IXGBE_SUCCESS)
1833 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
1834 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
1835 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
1836 status = ixgbe_write_iosf_sb_reg_x550(hw,
1837 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
1838 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1839 if (status != IXGBE_SUCCESS)
1842 /* Enable override for coefficients. */
1843 status = ixgbe_read_iosf_sb_reg_x550(hw,
1844 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
1845 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1846 if (status != IXGBE_SUCCESS)
1848 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
1849 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
1850 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
1851 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
1852 status = ixgbe_write_iosf_sb_reg_x550(hw,
1853 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
1854 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1855 if (status != IXGBE_SUCCESS)
1858 /* Toggle port SW reset by AN reset. */
1859 status = ixgbe_read_iosf_sb_reg_x550(hw,
1860 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1861 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1862 if (status != IXGBE_SUCCESS)
1864 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1865 status = ixgbe_write_iosf_sb_reg_x550(hw,
1866 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1867 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1873 * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
1874 * @hw: address of hardware structure
1875 * @link_up: address of boolean to indicate link status
1877 * Returns error code if unable to get link status.
1879 STATIC s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
1886 /* read this twice back to back to indicate current status */
1887 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
1888 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1890 if (ret != IXGBE_SUCCESS)
1893 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
1894 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1896 if (ret != IXGBE_SUCCESS)
1899 *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
1901 return IXGBE_SUCCESS;
1905 * ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
1906 * @hw: pointer to hardware structure
1908 * Configure the external PHY and the integrated KR PHY for SFP support.
1910 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
1911 ixgbe_link_speed speed,
1912 bool autoneg_wait_to_complete)
1915 u16 reg_slice, reg_val;
1916 bool setup_linear = false;
1917 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
1919 /* Check if SFP module is supported and linear */
1920 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
1922 /* If no SFP module present, then return success. Return success since
1923 * there is no reason to configure CS4227 and SFP not present error is
1924 * not excepted in the setup MAC link flow.
1926 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
1927 return IXGBE_SUCCESS;
1929 if (ret_val != IXGBE_SUCCESS)
1932 /* Configure CS4227 for LINE connection rate then type. */
1933 reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB + (hw->bus.lan_id << 12);
1934 reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
1935 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1938 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
1940 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
1942 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1943 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1946 /* Configure CS4227 for HOST connection rate then type. */
1947 reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB + (hw->bus.lan_id << 12);
1948 reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
1949 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1952 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (hw->bus.lan_id << 12);
1954 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
1956 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1957 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1960 /* If internal link mode is XFI, then setup XFI internal link. */
1961 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE))
1962 ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
1968 * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
1969 * @hw: point to hardware structure
1971 * Configures the link between the integrated KR PHY and the external X557 PHY
1972 * The driver will call this function when it gets a link status change
1973 * interrupt from the X557 PHY. This function configures the link speed
1974 * between the PHYs to match the link speed of the BASE-T link.
1976 * A return of a non-zero value indicates an error, and the base driver should
1977 * not report link up.
1979 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
1981 ixgbe_link_speed force_speed;
1986 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
1987 return IXGBE_ERR_CONFIG;
1989 /* If link is not up, then there is no setup necessary so return */
1990 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
1991 if (status != IXGBE_SUCCESS)
1995 return IXGBE_SUCCESS;
1997 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
1998 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2000 if (status != IXGBE_SUCCESS)
2003 /* If link is not still up, then no setup is necessary so return */
2004 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2005 if (status != IXGBE_SUCCESS)
2008 return IXGBE_SUCCESS;
2010 /* clear everything but the speed and duplex bits */
2011 speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
2014 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
2015 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
2017 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
2018 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
2021 /* Internal PHY does not support anything else */
2022 return IXGBE_ERR_INVALID_LINK_SETTINGS;
2025 return ixgbe_setup_ixfi_x550em(hw, &force_speed);
2029 * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
2030 * @hw: pointer to hardware structure
2032 * Configures the integrated KR PHY to use internal loopback mode.
2034 s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
2039 /* Disable AN and force speed to 10G Serial. */
2040 status = ixgbe_read_iosf_sb_reg_x550(hw,
2041 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2042 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2043 if (status != IXGBE_SUCCESS)
2045 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2046 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2047 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2048 status = ixgbe_write_iosf_sb_reg_x550(hw,
2049 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2050 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2051 if (status != IXGBE_SUCCESS)
2054 /* Set near-end loopback clocks. */
2055 status = ixgbe_read_iosf_sb_reg_x550(hw,
2056 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
2057 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2058 if (status != IXGBE_SUCCESS)
2060 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
2061 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
2062 status = ixgbe_write_iosf_sb_reg_x550(hw,
2063 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
2064 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2065 if (status != IXGBE_SUCCESS)
2068 /* Set loopback enable. */
2069 status = ixgbe_read_iosf_sb_reg_x550(hw,
2070 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
2071 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2072 if (status != IXGBE_SUCCESS)
2074 reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
2075 status = ixgbe_write_iosf_sb_reg_x550(hw,
2076 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
2077 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2078 if (status != IXGBE_SUCCESS)
2081 /* Training bypass. */
2082 status = ixgbe_read_iosf_sb_reg_x550(hw,
2083 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2084 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2085 if (status != IXGBE_SUCCESS)
2087 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
2088 status = ixgbe_write_iosf_sb_reg_x550(hw,
2089 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2090 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2096 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2097 * assuming that the semaphore is already obtained.
2098 * @hw: pointer to hardware structure
2099 * @offset: offset of word in the EEPROM to read
2100 * @data: word read from the EEPROM
2102 * Reads a 16 bit word from the EEPROM using the hostif.
2104 s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2108 struct ixgbe_hic_read_shadow_ram buffer;
2110 DEBUGFUNC("ixgbe_read_ee_hostif_data_X550");
2111 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2112 buffer.hdr.req.buf_lenh = 0;
2113 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2114 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2116 /* convert offset from words to bytes */
2117 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2119 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2121 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2123 IXGBE_HI_COMMAND_TIMEOUT, false);
2128 *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
2129 FW_NVM_DATA_OFFSET);
2135 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2136 * @hw: pointer to hardware structure
2137 * @offset: offset of word in the EEPROM to read
2138 * @data: word read from the EEPROM
2140 * Reads a 16 bit word from the EEPROM using the hostif.
2142 s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2145 s32 status = IXGBE_SUCCESS;
2147 DEBUGFUNC("ixgbe_read_ee_hostif_X550");
2149 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2151 status = ixgbe_read_ee_hostif_data_X550(hw, offset, data);
2152 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2154 status = IXGBE_ERR_SWFW_SYNC;
2161 * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
2162 * @hw: pointer to hardware structure
2163 * @offset: offset of word in the EEPROM to read
2164 * @words: number of words
2165 * @data: word(s) read from the EEPROM
2167 * Reads a 16 bit word(s) from the EEPROM using the hostif.
2169 s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2170 u16 offset, u16 words, u16 *data)
2172 struct ixgbe_hic_read_shadow_ram buffer;
2173 u32 current_word = 0;
2178 DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
2180 /* Take semaphore for the entire operation. */
2181 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2183 DEBUGOUT("EEPROM read buffer - semaphore failed\n");
2187 if (words > FW_MAX_READ_BUFFER_SIZE / 2)
2188 words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
2190 words_to_read = words;
2192 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2193 buffer.hdr.req.buf_lenh = 0;
2194 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2195 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2197 /* convert offset from words to bytes */
2198 buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
2199 buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
2201 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2203 IXGBE_HI_COMMAND_TIMEOUT,
2207 DEBUGOUT("Host interface command failed\n");
2211 for (i = 0; i < words_to_read; i++) {
2212 u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
2214 u32 value = IXGBE_READ_REG(hw, reg);
2216 data[current_word] = (u16)(value & 0xffff);
2219 if (i < words_to_read) {
2221 data[current_word] = (u16)(value & 0xffff);
2225 words -= words_to_read;
2229 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2234 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2235 * @hw: pointer to hardware structure
2236 * @offset: offset of word in the EEPROM to write
2237 * @data: word write to the EEPROM
2239 * Write a 16 bit word to the EEPROM using the hostif.
2241 s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2245 struct ixgbe_hic_write_shadow_ram buffer;
2247 DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
2249 buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
2250 buffer.hdr.req.buf_lenh = 0;
2251 buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
2252 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2255 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2257 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2259 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2261 IXGBE_HI_COMMAND_TIMEOUT, false);
2267 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2268 * @hw: pointer to hardware structure
2269 * @offset: offset of word in the EEPROM to write
2270 * @data: word write to the EEPROM
2272 * Write a 16 bit word to the EEPROM using the hostif.
2274 s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2277 s32 status = IXGBE_SUCCESS;
2279 DEBUGFUNC("ixgbe_write_ee_hostif_X550");
2281 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2283 status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
2284 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2286 DEBUGOUT("write ee hostif failed to get semaphore");
2287 status = IXGBE_ERR_SWFW_SYNC;
2294 * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
2295 * @hw: pointer to hardware structure
2296 * @offset: offset of word in the EEPROM to write
2297 * @words: number of words
2298 * @data: word(s) write to the EEPROM
2300 * Write a 16 bit word(s) to the EEPROM using the hostif.
2302 s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2303 u16 offset, u16 words, u16 *data)
2305 s32 status = IXGBE_SUCCESS;
2308 DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
2310 /* Take semaphore for the entire operation. */
2311 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2312 if (status != IXGBE_SUCCESS) {
2313 DEBUGOUT("EEPROM write buffer - semaphore failed\n");
2317 for (i = 0; i < words; i++) {
2318 status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
2321 if (status != IXGBE_SUCCESS) {
2322 DEBUGOUT("Eeprom buffered write failed\n");
2327 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2334 * ixgbe_checksum_ptr_x550 - Checksum one pointer region
2335 * @hw: pointer to hardware structure
2336 * @ptr: pointer offset in eeprom
2337 * @size: size of section pointed by ptr, if 0 first word will be used as size
2338 * @csum: address of checksum to update
2340 * Returns error status for any failure
2342 STATIC s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
2343 u16 size, u16 *csum, u16 *buffer,
2348 u16 length, bufsz, i, start;
2351 bufsz = sizeof(buf) / sizeof(buf[0]);
2353 /* Read a chunk at the pointer location */
2355 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
2357 DEBUGOUT("Failed to read EEPROM image\n");
2362 if (buffer_size < ptr)
2363 return IXGBE_ERR_PARAM;
2364 local_buffer = &buffer[ptr];
2372 length = local_buffer[0];
2374 /* Skip pointer section if length is invalid. */
2375 if (length == 0xFFFF || length == 0 ||
2376 (ptr + length) >= hw->eeprom.word_size)
2377 return IXGBE_SUCCESS;
2380 if (buffer && ((u32)start + (u32)length > buffer_size))
2381 return IXGBE_ERR_PARAM;
2383 for (i = start; length; i++, length--) {
2384 if (i == bufsz && !buffer) {
2390 /* Read a chunk at the pointer location */
2391 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
2394 DEBUGOUT("Failed to read EEPROM image\n");
2398 *csum += local_buffer[i];
2400 return IXGBE_SUCCESS;
2404 * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
2405 * @hw: pointer to hardware structure
2406 * @buffer: pointer to buffer containing calculated checksum
2407 * @buffer_size: size of buffer
2409 * Returns a negative error code on error, or the 16-bit checksum
2411 s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
2413 u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
2417 u16 pointer, i, size;
2419 DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
2421 hw->eeprom.ops.init_params(hw);
2424 /* Read pointer area */
2425 status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
2426 IXGBE_EEPROM_LAST_WORD + 1,
2429 DEBUGOUT("Failed to read EEPROM image\n");
2432 local_buffer = eeprom_ptrs;
2434 if (buffer_size < IXGBE_EEPROM_LAST_WORD)
2435 return IXGBE_ERR_PARAM;
2436 local_buffer = buffer;
2440 * For X550 hardware include 0x0-0x41 in the checksum, skip the
2441 * checksum word itself
2443 for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
2444 if (i != IXGBE_EEPROM_CHECKSUM)
2445 checksum += local_buffer[i];
2448 * Include all data from pointers 0x3, 0x6-0xE. This excludes the
2449 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
2451 for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
2452 if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
2455 pointer = local_buffer[i];
2457 /* Skip pointer section if the pointer is invalid. */
2458 if (pointer == 0xFFFF || pointer == 0 ||
2459 pointer >= hw->eeprom.word_size)
2463 case IXGBE_PCIE_GENERAL_PTR:
2464 size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
2466 case IXGBE_PCIE_CONFIG0_PTR:
2467 case IXGBE_PCIE_CONFIG1_PTR:
2468 size = IXGBE_PCIE_CONFIG_SIZE;
2475 status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
2476 buffer, buffer_size);
2481 checksum = (u16)IXGBE_EEPROM_SUM - checksum;
2483 return (s32)checksum;
2487 * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
2488 * @hw: pointer to hardware structure
2490 * Returns a negative error code on error, or the 16-bit checksum
2492 s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
2494 return ixgbe_calc_checksum_X550(hw, NULL, 0);
2498 * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
2499 * @hw: pointer to hardware structure
2500 * @checksum_val: calculated checksum
2502 * Performs checksum calculation and validates the EEPROM checksum. If the
2503 * caller does not need checksum_val, the value can be NULL.
2505 s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
2509 u16 read_checksum = 0;
2511 DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
2513 /* Read the first word from the EEPROM. If this times out or fails, do
2514 * not continue or we could be in for a very long wait while every
2517 status = hw->eeprom.ops.read(hw, 0, &checksum);
2519 DEBUGOUT("EEPROM read failed\n");
2523 status = hw->eeprom.ops.calc_checksum(hw);
2527 checksum = (u16)(status & 0xffff);
2529 status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
2534 /* Verify read checksum from EEPROM is the same as
2535 * calculated checksum
2537 if (read_checksum != checksum) {
2538 status = IXGBE_ERR_EEPROM_CHECKSUM;
2539 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
2540 "Invalid EEPROM checksum");
2543 /* If the user cares, return the calculated checksum */
2545 *checksum_val = checksum;
2551 * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
2552 * @hw: pointer to hardware structure
2554 * After writing EEPROM to shadow RAM using EEWR register, software calculates
2555 * checksum and updates the EEPROM and instructs the hardware to update
2558 s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
2563 DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
2565 /* Read the first word from the EEPROM. If this times out or fails, do
2566 * not continue or we could be in for a very long wait while every
2569 status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
2571 DEBUGOUT("EEPROM read failed\n");
2575 status = ixgbe_calc_eeprom_checksum_X550(hw);
2579 checksum = (u16)(status & 0xffff);
2581 status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
2586 status = ixgbe_update_flash_X550(hw);
2592 * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
2593 * @hw: pointer to hardware structure
2595 * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
2597 s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
2599 s32 status = IXGBE_SUCCESS;
2600 union ixgbe_hic_hdr2 buffer;
2602 DEBUGFUNC("ixgbe_update_flash_X550");
2604 buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
2605 buffer.req.buf_lenh = 0;
2606 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
2607 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
2609 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2611 IXGBE_HI_COMMAND_TIMEOUT, false);
2617 * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
2618 * @hw: pointer to hardware structure
2620 * Determines physical layer capabilities of the current configuration.
2622 u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
2624 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
2625 u16 ext_ability = 0;
2627 DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
2629 hw->phy.ops.identify(hw);
2631 switch (hw->phy.type) {
2632 case ixgbe_phy_x550em_kr:
2633 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
2634 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2636 case ixgbe_phy_x550em_kx4:
2637 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
2638 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2640 case ixgbe_phy_x550em_ext_t:
2641 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
2642 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
2644 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
2645 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
2646 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
2647 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
2653 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
2654 physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
2656 return physical_layer;
2660 * ixgbe_get_bus_info_x550em - Set PCI bus info
2661 * @hw: pointer to hardware structure
2663 * Sets bus link width and speed to unknown because X550em is
2666 s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
2669 DEBUGFUNC("ixgbe_get_bus_info_x550em");
2671 hw->bus.width = ixgbe_bus_width_unknown;
2672 hw->bus.speed = ixgbe_bus_speed_unknown;
2674 hw->mac.ops.set_lan_id(hw);
2676 return IXGBE_SUCCESS;
2680 * ixgbe_disable_rx_x550 - Disable RX unit
2682 * Enables the Rx DMA unit for x550
2684 void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
2686 u32 rxctrl, pfdtxgswc;
2688 struct ixgbe_hic_disable_rxen fw_cmd;
2690 DEBUGFUNC("ixgbe_enable_rx_dma_x550");
2692 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
2693 if (rxctrl & IXGBE_RXCTRL_RXEN) {
2694 pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
2695 if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
2696 pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
2697 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
2698 hw->mac.set_lben = true;
2700 hw->mac.set_lben = false;
2703 fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
2704 fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
2705 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
2706 fw_cmd.port_number = (u8)hw->bus.lan_id;
2708 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
2709 sizeof(struct ixgbe_hic_disable_rxen),
2710 IXGBE_HI_COMMAND_TIMEOUT, true);
2712 /* If we fail - disable RX using register write */
2714 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
2715 if (rxctrl & IXGBE_RXCTRL_RXEN) {
2716 rxctrl &= ~IXGBE_RXCTRL_RXEN;
2717 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
2724 * ixgbe_enter_lplu_x550em - Transition to low power states
2725 * @hw: pointer to hardware structure
2727 * Configures Low Power Link Up on transition to low power states
2728 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
2729 * X557 PHY immediately prior to entering LPLU.
2731 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
2733 u16 an_10g_cntl_reg, autoneg_reg, speed;
2735 ixgbe_link_speed lcd_speed;
2739 /* If blocked by MNG FW, then don't restart AN */
2740 if (ixgbe_check_reset_blocked(hw))
2741 return IXGBE_SUCCESS;
2743 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2744 if (status != IXGBE_SUCCESS)
2747 status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
2749 if (status != IXGBE_SUCCESS)
2752 /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
2753 * disabled, then force link down by entering low power mode.
2755 if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
2756 !(hw->wol_enabled || ixgbe_mng_present(hw)))
2757 return ixgbe_set_copper_phy_power(hw, FALSE);
2760 status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
2762 if (status != IXGBE_SUCCESS)
2765 /* If no valid LCD link speed, then force link down and exit. */
2766 if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
2767 return ixgbe_set_copper_phy_power(hw, FALSE);
2769 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
2770 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2773 if (status != IXGBE_SUCCESS)
2776 /* If no link now, speed is invalid so take link down */
2777 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2778 if (status != IXGBE_SUCCESS)
2779 return ixgbe_set_copper_phy_power(hw, false);
2781 /* clear everything but the speed bits */
2782 speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
2784 /* If current speed is already LCD, then exit. */
2785 if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
2786 (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
2787 ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
2788 (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
2791 /* Clear AN completed indication */
2792 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
2793 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2796 if (status != IXGBE_SUCCESS)
2799 status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
2800 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2803 if (status != IXGBE_SUCCESS)
2806 status = hw->phy.ops.read_reg(hw,
2807 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
2808 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2811 if (status != IXGBE_SUCCESS)
2814 save_autoneg = hw->phy.autoneg_advertised;
2816 /* Setup link at least common link speed */
2817 status = hw->mac.ops.setup_link(hw, lcd_speed, false);
2819 /* restore autoneg from before setting lplu speed */
2820 hw->phy.autoneg_advertised = save_autoneg;
2826 * ixgbe_get_lcd_x550em - Determine lowest common denominator
2827 * @hw: pointer to hardware structure
2828 * @lcd_speed: pointer to lowest common link speed
2830 * Determine lowest common link speed with link partner.
2832 s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
2836 u16 word = hw->eeprom.ctrl_word_3;
2838 *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
2840 status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
2841 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2844 if (status != IXGBE_SUCCESS)
2847 /* If link partner advertised 1G, return 1G */
2848 if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
2849 *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
2853 /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
2854 if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
2855 (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
2858 /* Link partner not capable of lower speeds, return 10G */
2859 *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
2864 * ixgbe_setup_fc_X550em - Set up flow control
2865 * @hw: pointer to hardware structure
2867 * Called at init time to set up flow control.
2869 s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
2871 s32 ret_val = IXGBE_SUCCESS;
2872 u32 pause, asm_dir, reg_val;
2874 DEBUGFUNC("ixgbe_setup_fc_X550em");
2876 /* Validate the requested mode */
2877 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
2878 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
2879 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
2880 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
2884 /* 10gig parts do not have a word in the EEPROM to determine the
2885 * default flow control setting, so we explicitly set it to full.
2887 if (hw->fc.requested_mode == ixgbe_fc_default)
2888 hw->fc.requested_mode = ixgbe_fc_full;
2890 /* Determine PAUSE and ASM_DIR bits. */
2891 switch (hw->fc.requested_mode) {
2896 case ixgbe_fc_tx_pause:
2900 case ixgbe_fc_rx_pause:
2901 /* Rx Flow control is enabled and Tx Flow control is
2902 * disabled by software override. Since there really
2903 * isn't a way to advertise that we are capable of RX
2904 * Pause ONLY, we will advertise that we support both
2905 * symmetric and asymmetric Rx PAUSE, as such we fall
2906 * through to the fc_full statement. Later, we will
2907 * disable the adapter's ability to send PAUSE frames.
2914 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
2915 "Flow control param set incorrectly\n");
2916 ret_val = IXGBE_ERR_CONFIG;
2920 if (hw->phy.media_type == ixgbe_media_type_backplane) {
2921 ret_val = ixgbe_read_iosf_sb_reg_x550(hw,
2922 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
2923 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2924 if (ret_val != IXGBE_SUCCESS)
2926 reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
2927 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
2929 reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
2931 reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
2932 ret_val = ixgbe_write_iosf_sb_reg_x550(hw,
2933 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
2934 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2936 /* Not all devices fully support AN. */
2937 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR)
2938 hw->fc.disable_fc_autoneg = true;
2946 * ixgbe_set_mux - Set mux for port 1 access with CS4227
2947 * @hw: pointer to hardware structure
2948 * @state: set mux if 1, clear if 0
2950 STATIC void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
2954 if (!hw->bus.lan_id)
2956 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
2958 esdp |= IXGBE_ESDP_SDP1;
2960 esdp &= ~IXGBE_ESDP_SDP1;
2961 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
2962 IXGBE_WRITE_FLUSH(hw);
2966 * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
2967 * @hw: pointer to hardware structure
2968 * @mask: Mask to specify which semaphore to acquire
2970 * Acquires the SWFW semaphore and sets the I2C MUX
2972 s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
2976 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
2978 status = ixgbe_acquire_swfw_sync_X540(hw, mask);
2982 if (mask & IXGBE_GSSR_I2C_MASK)
2983 ixgbe_set_mux(hw, 1);
2985 return IXGBE_SUCCESS;
2989 * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
2990 * @hw: pointer to hardware structure
2991 * @mask: Mask to specify which semaphore to release
2993 * Releases the SWFW semaphore and sets the I2C MUX
2995 void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
2997 DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
2999 if (mask & IXGBE_GSSR_I2C_MASK)
3000 ixgbe_set_mux(hw, 0);
3002 ixgbe_release_swfw_sync_X540(hw, mask);
3006 * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
3007 * @hw: pointer to hardware structure
3009 * Handle external Base T PHY interrupt. If high temperature
3010 * failure alarm then return error, else if link status change
3011 * then setup internal/external PHY link
3013 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
3014 * failure alarm, else return PHY access status.
3016 s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
3021 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
3023 if (status != IXGBE_SUCCESS)
3027 return ixgbe_setup_internal_phy(hw);
3029 return IXGBE_SUCCESS;
3033 * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
3034 * @hw: pointer to hardware structure
3035 * @speed: new link speed
3036 * @autoneg_wait_to_complete: true when waiting for completion is needed
3038 * Setup internal/external PHY link speed based on link speed, then set
3039 * external PHY auto advertised link speed.
3041 * Returns error status for any failure
3043 s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
3044 ixgbe_link_speed speed,
3045 bool autoneg_wait_to_complete)
3048 ixgbe_link_speed force_speed;
3050 DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
3052 /* Setup internal/external PHY link speed to iXFI (10G), unless
3053 * only 1G is auto advertised then setup KX link.
3055 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
3056 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
3058 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
3060 /* If internal link mode is XFI, then setup XFI internal link. */
3061 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
3062 status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
3064 if (status != IXGBE_SUCCESS)
3068 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
3072 * ixgbe_check_link_t_X550em - Determine link and speed status
3073 * @hw: pointer to hardware structure
3074 * @speed: pointer to link speed
3075 * @link_up: true when link is up
3076 * @link_up_wait_to_complete: bool used to wait for link up or not
3078 * Check that both the MAC and X557 external PHY have link.
3080 s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
3081 bool *link_up, bool link_up_wait_to_complete)
3086 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
3087 return IXGBE_ERR_CONFIG;
3089 status = ixgbe_check_mac_link_generic(hw, speed, link_up,
3090 link_up_wait_to_complete);
3092 /* If check link fails or MAC link is not up, then return */
3093 if (status != IXGBE_SUCCESS || !(*link_up))
3096 /* MAC link is up, so check external PHY link.
3097 * Read this twice back to back to indicate current status.
3099 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3100 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3103 if (status != IXGBE_SUCCESS)
3106 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3107 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3110 if (status != IXGBE_SUCCESS)
3113 /* If external PHY link is not up, then indicate link not up */
3114 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
3117 return IXGBE_SUCCESS;
3121 * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
3122 * @hw: pointer to hardware structure
3124 s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
3128 status = ixgbe_reset_phy_generic(hw);
3130 if (status != IXGBE_SUCCESS)
3133 /* Configure Link Status Alarm and Temperature Threshold interrupts */
3134 return ixgbe_enable_lasi_ext_t_x550em(hw);