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 ******************************************************************************/
35 #include "ixgbe_x550.h"
36 #include "ixgbe_x540.h"
37 #include "ixgbe_type.h"
38 #include "ixgbe_api.h"
39 #include "ixgbe_common.h"
40 #include "ixgbe_phy.h"
42 static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed);
45 * ixgbe_init_ops_X550 - Inits func ptrs and MAC type
46 * @hw: pointer to hardware structure
48 * Initialize the function pointers and assign the MAC type for X550.
49 * Does not touch the hardware.
51 s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
53 struct ixgbe_mac_info *mac = &hw->mac;
54 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
57 DEBUGFUNC("ixgbe_init_ops_X550");
59 ret_val = ixgbe_init_ops_X540(hw);
60 mac->ops.dmac_config = ixgbe_dmac_config_X550;
61 mac->ops.dmac_config_tcs = ixgbe_dmac_config_tcs_X550;
62 mac->ops.dmac_update_tcs = ixgbe_dmac_update_tcs_X550;
63 mac->ops.setup_eee = ixgbe_setup_eee_X550;
64 mac->ops.set_source_address_pruning =
65 ixgbe_set_source_address_pruning_X550;
66 mac->ops.set_ethertype_anti_spoofing =
67 ixgbe_set_ethertype_anti_spoofing_X550;
69 mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
70 eeprom->ops.init_params = ixgbe_init_eeprom_params_X550;
71 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
72 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
73 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
74 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
75 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
76 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
77 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
79 mac->ops.disable_mdd = ixgbe_disable_mdd_X550;
80 mac->ops.enable_mdd = ixgbe_enable_mdd_X550;
81 mac->ops.mdd_event = ixgbe_mdd_event_X550;
82 mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
83 mac->ops.disable_rx = ixgbe_disable_rx_x550;
84 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
85 hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
86 hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
92 * ixgbe_read_cs4227 - Read CS4227 register
93 * @hw: pointer to hardware structure
94 * @reg: register number to write
95 * @value: pointer to receive value read
99 static s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
101 return ixgbe_read_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
105 * ixgbe_write_cs4227 - Write CS4227 register
106 * @hw: pointer to hardware structure
107 * @reg: register number to write
108 * @value: value to write to register
110 * Returns status code
112 static s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
114 return ixgbe_write_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
118 * ixgbe_get_cs4227_status - Return CS4227 status
119 * @hw: pointer to hardware structure
121 * Returns error if CS4227 not successfully initialized
123 static s32 ixgbe_get_cs4227_status(struct ixgbe_hw *hw)
127 u16 reg_slice, reg_val;
130 for (retry = 0; retry < IXGBE_CS4227_RETRIES; ++retry) {
131 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_GLOBAL_ID_LSB,
133 if (status != IXGBE_SUCCESS)
135 if (value == IXGBE_CS4227_GLOBAL_ID_VALUE)
137 msec_delay(IXGBE_CS4227_CHECK_DELAY);
139 if (value != IXGBE_CS4227_GLOBAL_ID_VALUE)
140 return IXGBE_ERR_PHY;
142 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
143 if (status != IXGBE_SUCCESS)
146 /* If this is the first time after power-on, check the ucode.
147 * Otherwise, this will disrupt link on all ports. Because we
148 * can only do this the first time, we must check all ports,
151 if (value != IXGBE_CS4227_SCRATCH_VALUE) {
152 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
153 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
154 status = ixgbe_write_cs4227(hw, reg_slice,
156 if (status != IXGBE_SUCCESS)
159 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB;
160 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
161 status = ixgbe_write_cs4227(hw, reg_slice,
163 if (status != IXGBE_SUCCESS)
166 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
167 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
168 status = ixgbe_write_cs4227(hw, reg_slice,
170 if (status != IXGBE_SUCCESS)
173 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (1 << 12);
174 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
175 status = ixgbe_write_cs4227(hw, reg_slice,
177 if (status != IXGBE_SUCCESS)
183 /* Verify that the ucode is operational on all ports. */
184 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
186 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
187 if (status != IXGBE_SUCCESS)
190 return IXGBE_ERR_PHY;
192 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB;
194 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
195 if (status != IXGBE_SUCCESS)
198 return IXGBE_ERR_PHY;
200 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
202 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
203 if (status != IXGBE_SUCCESS)
206 return IXGBE_ERR_PHY;
208 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (1 << 12);
210 status = ixgbe_read_cs4227(hw, reg_slice, ®_val);
211 if (status != IXGBE_SUCCESS)
214 return IXGBE_ERR_PHY;
216 /* Set scratch for next time. */
217 status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
218 IXGBE_CS4227_SCRATCH_VALUE);
219 if (status != IXGBE_SUCCESS)
221 status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
222 if (status != IXGBE_SUCCESS)
224 if (value != IXGBE_CS4227_SCRATCH_VALUE)
225 return IXGBE_ERR_PHY;
227 return IXGBE_SUCCESS;
231 * ixgbe_read_pe - Read register from port expander
232 * @hw: pointer to hardware structure
233 * @reg: register number to read
234 * @value: pointer to receive read value
236 * Returns status code
238 static s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
242 status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
243 if (status != IXGBE_SUCCESS)
244 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
245 "port expander access failed with %d\n", status);
250 * ixgbe_write_pe - Write register to port expander
251 * @hw: pointer to hardware structure
252 * @reg: register number to write
253 * @value: value to write
255 * Returns status code
257 static s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
261 status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
262 if (status != IXGBE_SUCCESS)
263 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
264 "port expander access failed with %d\n", status);
269 * ixgbe_reset_cs4227 - Reset CS4227 using port expander
270 * @hw: pointer to hardware structure
274 static s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
279 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
280 if (status != IXGBE_SUCCESS)
282 reg |= IXGBE_PE_BIT1;
283 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
284 if (status != IXGBE_SUCCESS)
287 status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, ®);
288 if (status != IXGBE_SUCCESS)
290 reg &= ~IXGBE_PE_BIT1;
291 status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
292 if (status != IXGBE_SUCCESS)
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 usec_delay(IXGBE_CS4227_RESET_HOLD);
305 status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, ®);
306 if (status != IXGBE_SUCCESS)
308 reg |= IXGBE_PE_BIT1;
309 status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
310 if (status != IXGBE_SUCCESS)
313 msec_delay(IXGBE_CS4227_RESET_DELAY);
315 return IXGBE_SUCCESS;
319 * ixgbe_check_cs4227 - Check CS4227 and reset as needed
320 * @hw: pointer to hardware structure
322 static void ixgbe_check_cs4227(struct ixgbe_hw *hw)
324 u32 swfw_mask = hw->phy.phy_semaphore_mask;
328 for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
329 status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
330 if (status != IXGBE_SUCCESS) {
331 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
332 "semaphore failed with %d\n", status);
335 status = ixgbe_get_cs4227_status(hw);
336 if (status == IXGBE_SUCCESS) {
337 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
338 msec_delay(hw->eeprom.semaphore_delay);
341 ixgbe_reset_cs4227(hw);
342 hw->mac.ops.release_swfw_sync(hw, swfw_mask);
343 msec_delay(hw->eeprom.semaphore_delay);
345 ERROR_REPORT2(IXGBE_ERROR_CAUTION,
346 "Unable to initialize CS4227, err=%d\n", status);
350 * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
351 * @hw: pointer to hardware structure
353 static void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
355 u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
357 if (hw->bus.lan_id) {
358 esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
359 esdp |= IXGBE_ESDP_SDP1_DIR;
361 esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
362 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
363 IXGBE_WRITE_FLUSH(hw);
367 * ixgbe_identify_phy_x550em - Get PHY type based on device id
368 * @hw: pointer to hardware structure
372 static s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
374 switch (hw->device_id) {
375 case IXGBE_DEV_ID_X550EM_X_SFP:
376 /* set up for CS4227 usage */
377 hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
378 ixgbe_setup_mux_ctl(hw);
379 ixgbe_check_cs4227(hw);
381 return ixgbe_identify_module_generic(hw);
383 case IXGBE_DEV_ID_X550EM_X_KX4:
384 hw->phy.type = ixgbe_phy_x550em_kx4;
386 case IXGBE_DEV_ID_X550EM_X_KR:
387 hw->phy.type = ixgbe_phy_x550em_kr;
389 case IXGBE_DEV_ID_X550EM_X_1G_T:
390 case IXGBE_DEV_ID_X550EM_X_10G_T:
391 return ixgbe_identify_phy_generic(hw);
395 return IXGBE_SUCCESS;
398 static s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
399 u32 device_type, u16 *phy_data)
401 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
402 return IXGBE_NOT_IMPLEMENTED;
405 static s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
406 u32 device_type, u16 phy_data)
408 UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
409 return IXGBE_NOT_IMPLEMENTED;
413 * ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
414 * @hw: pointer to hardware structure
416 * Initialize the function pointers and for MAC type X550EM.
417 * Does not touch the hardware.
419 s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
421 struct ixgbe_mac_info *mac = &hw->mac;
422 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
423 struct ixgbe_phy_info *phy = &hw->phy;
426 DEBUGFUNC("ixgbe_init_ops_X550EM");
428 /* Similar to X550 so start there. */
429 ret_val = ixgbe_init_ops_X550(hw);
431 /* Since this function eventually calls
432 * ixgbe_init_ops_540 by design, we are setting
433 * the pointers to NULL explicitly here to overwrite
434 * the values being set in the x540 function.
437 /* FCOE not supported in x550EM */
438 mac->ops.get_san_mac_addr = NULL;
439 mac->ops.set_san_mac_addr = NULL;
440 mac->ops.get_wwn_prefix = NULL;
441 mac->ops.get_fcoe_boot_status = NULL;
443 /* IPsec not supported in x550EM */
444 mac->ops.disable_sec_rx_path = NULL;
445 mac->ops.enable_sec_rx_path = NULL;
447 /* AUTOC register is not present in x550EM. */
448 mac->ops.prot_autoc_read = NULL;
449 mac->ops.prot_autoc_write = NULL;
451 /* X550EM bus type is internal*/
452 hw->bus.type = ixgbe_bus_type_internal;
453 mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
455 mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
456 mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
457 mac->ops.get_media_type = ixgbe_get_media_type_X550em;
458 mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
459 mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
460 mac->ops.reset_hw = ixgbe_reset_hw_X550em;
461 mac->ops.get_supported_physical_layer =
462 ixgbe_get_supported_physical_layer_X550em;
464 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
465 mac->ops.setup_fc = ixgbe_setup_fc_generic;
467 mac->ops.setup_fc = ixgbe_setup_fc_X550em;
469 mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
470 mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
472 if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
473 mac->ops.setup_eee = NULL;
476 phy->ops.init = ixgbe_init_phy_ops_X550em;
477 phy->ops.identify = ixgbe_identify_phy_x550em;
478 if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
479 phy->ops.set_phy_power = NULL;
483 eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
484 eeprom->ops.read = ixgbe_read_ee_hostif_X550;
485 eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
486 eeprom->ops.write = ixgbe_write_ee_hostif_X550;
487 eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
488 eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
489 eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
490 eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
496 * ixgbe_dmac_config_X550
497 * @hw: pointer to hardware structure
499 * Configure DMA coalescing. If enabling dmac, dmac is activated.
500 * When disabling dmac, dmac enable dmac bit is cleared.
502 s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
504 u32 reg, high_pri_tc;
506 DEBUGFUNC("ixgbe_dmac_config_X550");
508 /* Disable DMA coalescing before configuring */
509 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
510 reg &= ~IXGBE_DMACR_DMAC_EN;
511 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
513 /* Disable DMA Coalescing if the watchdog timer is 0 */
514 if (!hw->mac.dmac_config.watchdog_timer)
517 ixgbe_dmac_config_tcs_X550(hw);
519 /* Configure DMA Coalescing Control Register */
520 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
522 /* Set the watchdog timer in units of 40.96 usec */
523 reg &= ~IXGBE_DMACR_DMACWT_MASK;
524 reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
526 reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
527 /* If fcoe is enabled, set high priority traffic class */
528 if (hw->mac.dmac_config.fcoe_en) {
529 high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
530 reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
531 IXGBE_DMACR_HIGH_PRI_TC_MASK);
533 reg |= IXGBE_DMACR_EN_MNG_IND;
535 /* Enable DMA coalescing after configuration */
536 reg |= IXGBE_DMACR_DMAC_EN;
537 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
540 return IXGBE_SUCCESS;
544 * ixgbe_dmac_config_tcs_X550
545 * @hw: pointer to hardware structure
547 * Configure DMA coalescing threshold per TC. The dmac enable bit must
548 * be cleared before configuring.
550 s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
552 u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
554 DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
556 /* Configure DMA coalescing enabled */
557 switch (hw->mac.dmac_config.link_speed) {
558 case IXGBE_LINK_SPEED_100_FULL:
559 pb_headroom = IXGBE_DMACRXT_100M;
561 case IXGBE_LINK_SPEED_1GB_FULL:
562 pb_headroom = IXGBE_DMACRXT_1G;
565 pb_headroom = IXGBE_DMACRXT_10G;
569 maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
570 IXGBE_MHADD_MFS_SHIFT) / 1024);
572 /* Set the per Rx packet buffer receive threshold */
573 for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
574 reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
575 reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
577 if (tc < hw->mac.dmac_config.num_tcs) {
579 rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
580 rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
581 IXGBE_RXPBSIZE_SHIFT;
583 /* Calculate receive buffer threshold in kilobytes */
584 if (rx_pb_size > pb_headroom)
585 rx_pb_size = rx_pb_size - pb_headroom;
589 /* Minimum of MFS shall be set for DMCTH */
590 reg |= (rx_pb_size > maxframe_size_kb) ?
591 rx_pb_size : maxframe_size_kb;
593 IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
595 return IXGBE_SUCCESS;
599 * ixgbe_dmac_update_tcs_X550
600 * @hw: pointer to hardware structure
602 * Disables dmac, updates per TC settings, and then enables dmac.
604 s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
608 DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
610 /* Disable DMA coalescing before configuring */
611 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
612 reg &= ~IXGBE_DMACR_DMAC_EN;
613 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
615 ixgbe_dmac_config_tcs_X550(hw);
617 /* Enable DMA coalescing after configuration */
618 reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
619 reg |= IXGBE_DMACR_DMAC_EN;
620 IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
622 return IXGBE_SUCCESS;
626 * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
627 * @hw: pointer to hardware structure
629 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
630 * ixgbe_hw struct in order to set up EEPROM access.
632 s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
634 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
638 DEBUGFUNC("ixgbe_init_eeprom_params_X550");
640 if (eeprom->type == ixgbe_eeprom_uninitialized) {
641 eeprom->semaphore_delay = 10;
642 eeprom->type = ixgbe_flash;
644 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
645 eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
646 IXGBE_EEC_SIZE_SHIFT);
647 eeprom->word_size = 1 << (eeprom_size +
648 IXGBE_EEPROM_WORD_SIZE_SHIFT);
650 DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
651 eeprom->type, eeprom->word_size);
654 return IXGBE_SUCCESS;
658 * ixgbe_setup_eee_X550 - Enable/disable EEE support
659 * @hw: pointer to the HW structure
660 * @enable_eee: boolean flag to enable EEE
662 * Enable/disable EEE based on enable_eee flag.
663 * Auto-negotiation must be started after BASE-T EEE bits in PHY register 7.3C
667 s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
675 DEBUGFUNC("ixgbe_setup_eee_X550");
677 eeer = IXGBE_READ_REG(hw, IXGBE_EEER);
678 /* Enable or disable EEE per flag */
680 eeer |= (IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
682 if (hw->device_id == IXGBE_DEV_ID_X550T) {
683 /* Advertise EEE capability */
684 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
685 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
687 autoneg_eee_reg |= (IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
688 IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
689 IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
691 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
692 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
693 } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
694 /* Not supported on first revision. */
695 fuse = IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0));
696 if (!(fuse & IXGBE_FUSES0_REV1))
697 return IXGBE_SUCCESS;
699 status = ixgbe_read_iosf_sb_reg_x550(hw,
700 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
701 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
702 if (status != IXGBE_SUCCESS)
705 link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
706 IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;
708 /* Don't advertise FEC capability when EEE enabled. */
709 link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
711 status = ixgbe_write_iosf_sb_reg_x550(hw,
712 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
713 IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
714 if (status != IXGBE_SUCCESS)
718 eeer &= ~(IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
720 if (hw->device_id == IXGBE_DEV_ID_X550T) {
721 /* Disable advertised EEE capability */
722 hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
723 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
725 autoneg_eee_reg &= ~(IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
726 IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
727 IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
729 hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
730 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
731 } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
732 status = ixgbe_read_iosf_sb_reg_x550(hw,
733 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
734 IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
735 if (status != IXGBE_SUCCESS)
738 link_reg &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
739 IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX);
741 /* Advertise FEC capability when EEE is disabled. */
742 link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
744 status = ixgbe_write_iosf_sb_reg_x550(hw,
745 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
746 IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
747 if (status != IXGBE_SUCCESS)
751 IXGBE_WRITE_REG(hw, IXGBE_EEER, eeer);
753 return IXGBE_SUCCESS;
757 * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
758 * @hw: pointer to hardware structure
759 * @enable: enable or disable source address pruning
760 * @pool: Rx pool to set source address pruning for
762 void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
767 /* max rx pool is 63 */
771 pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
772 pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
775 pfflp |= (1ULL << pool);
777 pfflp &= ~(1ULL << pool);
779 IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
780 IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
784 * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
785 * @hw: pointer to hardware structure
786 * @enable: enable or disable switch for Ethertype anti-spoofing
787 * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
790 void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
793 int vf_target_reg = vf >> 3;
794 int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
797 DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
799 pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
801 pfvfspoof |= (1 << vf_target_shift);
803 pfvfspoof &= ~(1 << vf_target_shift);
805 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
809 * ixgbe_iosf_wait - Wait for IOSF command completion
810 * @hw: pointer to hardware structure
811 * @ctrl: pointer to location to receive final IOSF control value
813 * Returns failing status on timeout
815 * Note: ctrl can be NULL if the IOSF control register value is not needed
817 static s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
821 /* Check every 10 usec to see if the address cycle completed.
822 * The SB IOSF BUSY bit will clear when the operation is
825 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
826 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
827 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
833 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
834 ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
835 return IXGBE_ERR_PHY;
838 return IXGBE_SUCCESS;
842 * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
844 * @hw: pointer to hardware structure
845 * @reg_addr: 32 bit PHY register to write
846 * @device_type: 3 bit device type
847 * @data: Data to write to the register
849 s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
850 u32 device_type, u32 data)
852 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
856 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
857 if (ret != IXGBE_SUCCESS)
860 ret = ixgbe_iosf_wait(hw, NULL);
861 if (ret != IXGBE_SUCCESS)
864 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
865 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
867 /* Write IOSF control register */
868 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
870 /* Write IOSF data register */
871 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
873 ret = ixgbe_iosf_wait(hw, &command);
875 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
876 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
877 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
878 ERROR_REPORT2(IXGBE_ERROR_POLLING,
879 "Failed to write, error %x\n", error);
884 ixgbe_release_swfw_semaphore(hw, gssr);
889 * ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
891 * @hw: pointer to hardware structure
892 * @reg_addr: 32 bit PHY register to write
893 * @device_type: 3 bit device type
894 * @phy_data: Pointer to read data from the register
896 s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
897 u32 device_type, u32 *data)
899 u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
903 ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
904 if (ret != IXGBE_SUCCESS)
907 ret = ixgbe_iosf_wait(hw, NULL);
908 if (ret != IXGBE_SUCCESS)
911 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
912 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
914 /* Write IOSF control register */
915 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
917 ret = ixgbe_iosf_wait(hw, &command);
919 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
920 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
921 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
922 ERROR_REPORT2(IXGBE_ERROR_POLLING,
923 "Failed to read, error %x\n", error);
927 if (ret == IXGBE_SUCCESS)
928 *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
931 ixgbe_release_swfw_semaphore(hw, gssr);
936 * ixgbe_disable_mdd_X550
937 * @hw: pointer to hardware structure
939 * Disable malicious driver detection
941 void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
945 DEBUGFUNC("ixgbe_disable_mdd_X550");
947 /* Disable MDD for TX DMA and interrupt */
948 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
949 reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
950 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
952 /* Disable MDD for RX and interrupt */
953 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
954 reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
955 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
959 * ixgbe_enable_mdd_X550
960 * @hw: pointer to hardware structure
962 * Enable malicious driver detection
964 void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
968 DEBUGFUNC("ixgbe_enable_mdd_X550");
970 /* Enable MDD for TX DMA and interrupt */
971 reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
972 reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
973 IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
975 /* Enable MDD for RX and interrupt */
976 reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
977 reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
978 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
982 * ixgbe_restore_mdd_vf_X550
983 * @hw: pointer to hardware structure
986 * Restore VF that was disabled during malicious driver detection event
988 void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
990 u32 idx, reg, num_qs, start_q, bitmask;
992 DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
994 /* Map VF to queues */
995 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
996 switch (reg & IXGBE_MRQC_MRQE_MASK) {
997 case IXGBE_MRQC_VMDQRT8TCEN:
998 num_qs = 8; /* 16 VFs / pools */
999 bitmask = 0x000000FF;
1001 case IXGBE_MRQC_VMDQRSS32EN:
1002 case IXGBE_MRQC_VMDQRT4TCEN:
1003 num_qs = 4; /* 32 VFs / pools */
1004 bitmask = 0x0000000F;
1006 default: /* 64 VFs / pools */
1008 bitmask = 0x00000003;
1011 start_q = vf * num_qs;
1013 /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
1016 reg |= (bitmask << (start_q % 32));
1017 IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
1018 IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
1022 * ixgbe_mdd_event_X550
1023 * @hw: pointer to hardware structure
1024 * @vf_bitmap: vf bitmap of malicious vfs
1026 * Handle malicious driver detection event.
1028 void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
1031 u32 i, j, reg, q, shift, vf, idx;
1033 DEBUGFUNC("ixgbe_mdd_event_X550");
1035 /* figure out pool size for mapping to vf's */
1036 reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
1037 switch (reg & IXGBE_MRQC_MRQE_MASK) {
1038 case IXGBE_MRQC_VMDQRT8TCEN:
1039 shift = 3; /* 16 VFs / pools */
1041 case IXGBE_MRQC_VMDQRSS32EN:
1042 case IXGBE_MRQC_VMDQRT4TCEN:
1043 shift = 2; /* 32 VFs / pools */
1046 shift = 1; /* 64 VFs / pools */
1050 /* Read WQBR_TX and WQBR_RX and check for malicious queues */
1051 for (i = 0; i < 4; i++) {
1052 wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
1053 wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
1058 /* Get malicious queue */
1059 for (j = 0; j < 32 && wqbr; j++) {
1061 if (!(wqbr & (1 << j)))
1064 /* Get queue from bitmask */
1067 /* Map queue to vf */
1070 /* Set vf bit in vf_bitmap */
1072 vf_bitmap[idx] |= (1 << (vf % 32));
1079 * ixgbe_get_media_type_X550em - Get media type
1080 * @hw: pointer to hardware structure
1082 * Returns the media type (fiber, copper, backplane)
1084 enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1086 enum ixgbe_media_type media_type;
1088 DEBUGFUNC("ixgbe_get_media_type_X550em");
1090 /* Detect if there is a copper PHY attached. */
1091 switch (hw->device_id) {
1092 case IXGBE_DEV_ID_X550EM_X_KR:
1093 case IXGBE_DEV_ID_X550EM_X_KX4:
1094 media_type = ixgbe_media_type_backplane;
1096 case IXGBE_DEV_ID_X550EM_X_SFP:
1097 media_type = ixgbe_media_type_fiber;
1099 case IXGBE_DEV_ID_X550EM_X_1G_T:
1100 case IXGBE_DEV_ID_X550EM_X_10G_T:
1101 media_type = ixgbe_media_type_copper;
1104 media_type = ixgbe_media_type_unknown;
1111 * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
1112 * @hw: pointer to hardware structure
1113 * @linear: TRUE if SFP module is linear
1115 static s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
1117 DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
1119 switch (hw->phy.sfp_type) {
1120 case ixgbe_sfp_type_not_present:
1121 return IXGBE_ERR_SFP_NOT_PRESENT;
1122 case ixgbe_sfp_type_da_cu_core0:
1123 case ixgbe_sfp_type_da_cu_core1:
1126 case ixgbe_sfp_type_srlr_core0:
1127 case ixgbe_sfp_type_srlr_core1:
1128 case ixgbe_sfp_type_da_act_lmt_core0:
1129 case ixgbe_sfp_type_da_act_lmt_core1:
1130 case ixgbe_sfp_type_1g_sx_core0:
1131 case ixgbe_sfp_type_1g_sx_core1:
1132 case ixgbe_sfp_type_1g_lx_core0:
1133 case ixgbe_sfp_type_1g_lx_core1:
1136 case ixgbe_sfp_type_unknown:
1137 case ixgbe_sfp_type_1g_cu_core0:
1138 case ixgbe_sfp_type_1g_cu_core1:
1140 return IXGBE_ERR_SFP_NOT_SUPPORTED;
1143 return IXGBE_SUCCESS;
1147 * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
1148 * @hw: pointer to hardware structure
1150 * Searches for and identifies the SFP module and assigns appropriate PHY type.
1152 s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
1157 DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
1159 status = ixgbe_identify_module_generic(hw);
1161 if (status != IXGBE_SUCCESS)
1164 /* Check if SFP module is supported */
1165 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1171 * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
1172 * @hw: pointer to hardware structure
1174 s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
1179 DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
1181 /* Check if SFP module is supported */
1182 status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
1184 if (status != IXGBE_SUCCESS)
1187 ixgbe_init_mac_link_ops_X550em(hw);
1188 hw->phy.ops.reset = NULL;
1190 return IXGBE_SUCCESS;
1194 * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
1195 * @hw: pointer to hardware structure
1197 void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
1199 struct ixgbe_mac_info *mac = &hw->mac;
1201 DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
1203 switch (hw->mac.ops.get_media_type(hw)) {
1204 case ixgbe_media_type_fiber:
1205 /* CS4227 does not support autoneg, so disable the laser control
1206 * functions for SFP+ fiber
1208 mac->ops.disable_tx_laser = NULL;
1209 mac->ops.enable_tx_laser = NULL;
1210 mac->ops.flap_tx_laser = NULL;
1211 mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
1212 mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_x550em;
1213 mac->ops.set_rate_select_speed =
1214 ixgbe_set_soft_rate_select_speed;
1216 case ixgbe_media_type_copper:
1217 mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
1218 mac->ops.check_link = ixgbe_check_link_t_X550em;
1226 * ixgbe_get_link_capabilities_x550em - Determines link capabilities
1227 * @hw: pointer to hardware structure
1228 * @speed: pointer to link speed
1229 * @autoneg: TRUE when autoneg or autotry is enabled
1231 s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
1232 ixgbe_link_speed *speed,
1235 DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
1238 if (hw->phy.media_type == ixgbe_media_type_fiber) {
1240 /* CS4227 SFP must not enable auto-negotiation */
1243 /* Check if 1G SFP module. */
1244 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
1245 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
1246 || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
1247 hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
1248 *speed = IXGBE_LINK_SPEED_1GB_FULL;
1249 return IXGBE_SUCCESS;
1252 /* Link capabilities are based on SFP */
1253 if (hw->phy.multispeed_fiber)
1254 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1255 IXGBE_LINK_SPEED_1GB_FULL;
1257 *speed = IXGBE_LINK_SPEED_10GB_FULL;
1259 *speed = IXGBE_LINK_SPEED_10GB_FULL |
1260 IXGBE_LINK_SPEED_1GB_FULL;
1264 return IXGBE_SUCCESS;
1268 * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
1269 * @hw: pointer to hardware structure
1270 * @lsc: pointer to boolean flag which indicates whether external Base T
1271 * PHY interrupt is lsc
1273 * Determime if external Base T PHY interrupt cause is high temperature
1274 * failure alarm or link status change.
1276 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
1277 * failure alarm, else return PHY access status.
1279 static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
1286 /* Vendor alarm triggered */
1287 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1288 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1291 if (status != IXGBE_SUCCESS ||
1292 !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
1295 /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
1296 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
1297 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1300 if (status != IXGBE_SUCCESS ||
1301 !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1302 IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
1305 /* High temperature failure alarm triggered */
1306 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
1307 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1310 if (status != IXGBE_SUCCESS)
1313 /* If high temperature failure, then return over temp error and exit */
1314 if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
1315 /* power down the PHY in case the PHY FW didn't already */
1316 ixgbe_set_copper_phy_power(hw, FALSE);
1317 return IXGBE_ERR_OVERTEMP;
1320 /* Vendor alarm 2 triggered */
1321 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
1322 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1324 if (status != IXGBE_SUCCESS ||
1325 !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
1328 /* link connect/disconnect event occurred */
1329 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
1330 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1332 if (status != IXGBE_SUCCESS)
1336 if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
1339 return IXGBE_SUCCESS;
1343 * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
1344 * @hw: pointer to hardware structure
1346 * Enable link status change and temperature failure alarm for the external
1349 * Returns PHY access status
1351 static s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
1357 /* Clear interrupt flags */
1358 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
1360 /* Enable link status change alarm */
1361 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1362 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, ®);
1364 if (status != IXGBE_SUCCESS)
1367 reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
1369 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
1370 IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
1372 if (status != IXGBE_SUCCESS)
1375 /* Enables high temperature failure alarm */
1376 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1377 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1380 if (status != IXGBE_SUCCESS)
1383 reg |= IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN;
1385 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
1386 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1389 if (status != IXGBE_SUCCESS)
1392 /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
1393 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1394 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1397 if (status != IXGBE_SUCCESS)
1400 reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
1401 IXGBE_MDIO_GLOBAL_ALARM_1_INT);
1403 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
1404 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1407 if (status != IXGBE_SUCCESS)
1410 /* Enable chip-wide vendor alarm */
1411 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1412 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1415 if (status != IXGBE_SUCCESS)
1418 reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
1420 status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
1421 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1428 * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
1429 * @hw: pointer to hardware structure
1430 * @speed: link speed
1432 * Configures the integrated KR PHY.
1434 static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
1435 ixgbe_link_speed speed)
1440 status = ixgbe_read_iosf_sb_reg_x550(hw,
1441 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1442 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1446 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1447 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ |
1448 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC);
1449 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
1450 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
1452 /* Advertise 10G support. */
1453 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
1454 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
1456 /* Advertise 1G support. */
1457 if (speed & IXGBE_LINK_SPEED_1GB_FULL)
1458 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
1460 /* Restart auto-negotiation. */
1461 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1462 status = ixgbe_write_iosf_sb_reg_x550(hw,
1463 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1464 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1470 * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
1471 * @hw: pointer to hardware structure
1473 * Initialize any function pointers that were not able to be
1474 * set during init_shared_code because the PHY/SFP type was
1475 * not known. Perform the SFP init if necessary.
1477 s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
1479 struct ixgbe_phy_info *phy = &hw->phy;
1480 ixgbe_link_speed speed;
1483 DEBUGFUNC("ixgbe_init_phy_ops_X550em");
1485 hw->mac.ops.set_lan_id(hw);
1487 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
1488 phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
1489 ixgbe_setup_mux_ctl(hw);
1491 /* Save NW management interface connected on board. This is used
1492 * to determine internal PHY mode.
1494 phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
1496 /* If internal PHY mode is KR, then initialize KR link */
1497 if (phy->nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE) {
1498 speed = IXGBE_LINK_SPEED_10GB_FULL |
1499 IXGBE_LINK_SPEED_1GB_FULL;
1500 ret_val = ixgbe_setup_kr_speed_x550em(hw, speed);
1503 phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
1506 /* Identify the PHY or SFP module */
1507 ret_val = phy->ops.identify(hw);
1508 if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED)
1511 /* Setup function pointers based on detected hardware */
1512 ixgbe_init_mac_link_ops_X550em(hw);
1513 if (phy->sfp_type != ixgbe_sfp_type_unknown)
1514 phy->ops.reset = NULL;
1516 /* Set functions pointers based on phy type */
1517 switch (hw->phy.type) {
1518 case ixgbe_phy_x550em_kx4:
1519 phy->ops.setup_link = ixgbe_setup_kx4_x550em;
1520 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1521 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1523 case ixgbe_phy_x550em_kr:
1524 phy->ops.setup_link = ixgbe_setup_kr_x550em;
1525 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1526 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1528 case ixgbe_phy_x550em_ext_t:
1529 /* Save NW management interface connected on board. This is used
1530 * to determine internal PHY mode
1532 phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
1534 /* If internal link mode is XFI, then setup iXFI internal link,
1535 * else setup KR now.
1537 if (!(phy->nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
1538 phy->ops.setup_internal_link =
1539 ixgbe_setup_internal_phy_t_x550em;
1541 speed = IXGBE_LINK_SPEED_10GB_FULL |
1542 IXGBE_LINK_SPEED_1GB_FULL;
1543 ret_val = ixgbe_setup_kr_speed_x550em(hw, speed);
1546 phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
1547 phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
1548 phy->ops.reset = ixgbe_reset_phy_t_X550em;
1557 * ixgbe_reset_hw_X550em - Perform hardware reset
1558 * @hw: pointer to hardware structure
1560 * Resets the hardware by resetting the transmit and receive units, masks
1561 * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
1564 s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
1566 ixgbe_link_speed link_speed;
1571 bool link_up = FALSE;
1573 DEBUGFUNC("ixgbe_reset_hw_X550em");
1575 /* Call adapter stop to disable Tx/Rx and clear interrupts */
1576 status = hw->mac.ops.stop_adapter(hw);
1577 if (status != IXGBE_SUCCESS)
1580 /* flush pending Tx transactions */
1581 ixgbe_clear_tx_pending(hw);
1583 /* PHY ops must be identified and initialized prior to reset */
1585 /* Identify PHY and related function pointers */
1586 status = hw->phy.ops.init(hw);
1588 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1591 /* start the external PHY */
1592 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
1593 status = ixgbe_init_ext_t_x550em(hw);
1598 /* Setup SFP module if there is one present. */
1599 if (hw->phy.sfp_setup_needed) {
1600 status = hw->mac.ops.setup_sfp(hw);
1601 hw->phy.sfp_setup_needed = FALSE;
1604 if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
1608 if (!hw->phy.reset_disable && hw->phy.ops.reset)
1609 hw->phy.ops.reset(hw);
1612 /* Issue global reset to the MAC. Needs to be SW reset if link is up.
1613 * If link reset is used when link is up, it might reset the PHY when
1614 * mng is using it. If link is down or the flag to force full link
1615 * reset is set, then perform link reset.
1617 ctrl = IXGBE_CTRL_LNK_RST;
1618 if (!hw->force_full_reset) {
1619 hw->mac.ops.check_link(hw, &link_speed, &link_up, FALSE);
1621 ctrl = IXGBE_CTRL_RST;
1624 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
1625 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
1626 IXGBE_WRITE_FLUSH(hw);
1628 /* Poll for reset bit to self-clear meaning reset is complete */
1629 for (i = 0; i < 10; i++) {
1631 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
1632 if (!(ctrl & IXGBE_CTRL_RST_MASK))
1636 if (ctrl & IXGBE_CTRL_RST_MASK) {
1637 status = IXGBE_ERR_RESET_FAILED;
1638 DEBUGOUT("Reset polling failed to complete.\n");
1643 /* Double resets are required for recovery from certain error
1644 * conditions. Between resets, it is necessary to stall to
1645 * allow time for any pending HW events to complete.
1647 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
1648 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
1652 /* Store the permanent mac address */
1653 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
1655 /* Store MAC address from RAR0, clear receive address registers, and
1656 * clear the multicast table. Also reset num_rar_entries to 128,
1657 * since we modify this value when programming the SAN MAC address.
1659 hw->mac.num_rar_entries = 128;
1660 hw->mac.ops.init_rx_addrs(hw);
1662 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
1663 /* Config MDIO clock speed. */
1664 hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
1665 hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
1666 IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
1669 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
1670 ixgbe_setup_mux_ctl(hw);
1676 * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
1677 * @hw: pointer to hardware structure
1679 s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
1684 status = hw->phy.ops.read_reg(hw,
1685 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
1686 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1689 if (status != IXGBE_SUCCESS)
1692 /* If PHY FW reset completed bit is set then this is the first
1693 * SW instance after a power on so the PHY FW must be un-stalled.
1695 if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
1696 status = hw->phy.ops.read_reg(hw,
1697 IXGBE_MDIO_GLOBAL_RES_PR_10,
1698 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1701 if (status != IXGBE_SUCCESS)
1704 reg &= ~IXGBE_MDIO_POWER_UP_STALL;
1706 status = hw->phy.ops.write_reg(hw,
1707 IXGBE_MDIO_GLOBAL_RES_PR_10,
1708 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1711 if (status != IXGBE_SUCCESS)
1719 * ixgbe_setup_kr_x550em - Configure the KR PHY.
1720 * @hw: pointer to hardware structure
1722 * Configures the integrated KR PHY.
1724 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
1726 return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
1730 * ixgbe_setup_kx4_x550em - Configure the KX4 PHY.
1731 * @hw: pointer to hardware structure
1733 * Configures the integrated KX4 PHY.
1735 s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw)
1740 status = ixgbe_read_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
1741 IXGBE_SB_IOSF_TARGET_KX4_PCS, ®_val);
1745 reg_val &= ~(IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4 |
1746 IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX);
1748 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_ENABLE;
1750 /* Advertise 10G support. */
1751 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1752 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4;
1754 /* Advertise 1G support. */
1755 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1756 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX;
1758 /* Restart auto-negotiation. */
1759 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_RESTART;
1760 status = ixgbe_write_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
1761 IXGBE_SB_IOSF_TARGET_KX4_PCS, reg_val);
1767 * ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
1768 * @hw: pointer to hardware structure
1770 * Configure the external PHY and the integrated KR PHY for SFP support.
1772 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
1773 ixgbe_link_speed speed,
1774 bool autoneg_wait_to_complete)
1777 u16 reg_slice, reg_val;
1778 bool setup_linear = FALSE;
1779 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
1781 /* Check if SFP module is supported and linear */
1782 ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
1784 /* If no SFP module present, then return success. Return success since
1785 * there is no reason to configure CS4227 and SFP not present error is
1786 * not excepted in the setup MAC link flow.
1788 if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
1789 return IXGBE_SUCCESS;
1791 if (ret_val != IXGBE_SUCCESS)
1794 /* Configure CS4227 for LINE connection rate then type. */
1795 reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB + (hw->bus.lan_id << 12);
1796 reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
1797 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1800 reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
1802 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
1804 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1805 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1808 /* Configure CS4227 for HOST connection rate then type. */
1809 reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB + (hw->bus.lan_id << 12);
1810 reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
1811 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1814 reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (hw->bus.lan_id << 12);
1816 reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
1818 reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
1819 ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
1822 /* If internal link mode is XFI, then setup XFI internal link. */
1823 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE))
1824 ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
1830 * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
1831 * @hw: pointer to hardware structure
1832 * @speed: the link speed to force
1834 * Configures the integrated KR PHY to use iXFI mode. Used to connect an
1835 * internal and external PHY at a specific speed, without autonegotiation.
1837 static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
1842 /* Disable AN and force speed to 10G Serial. */
1843 status = ixgbe_read_iosf_sb_reg_x550(hw,
1844 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1845 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1846 if (status != IXGBE_SUCCESS)
1849 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1850 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
1852 /* Select forced link speed for internal PHY. */
1854 case IXGBE_LINK_SPEED_10GB_FULL:
1855 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
1857 case IXGBE_LINK_SPEED_1GB_FULL:
1858 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
1861 /* Other link speeds are not supported by internal KR PHY. */
1862 return IXGBE_ERR_LINK_SETUP;
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);
1868 if (status != IXGBE_SUCCESS)
1871 /* Disable training protocol FSM. */
1872 status = ixgbe_read_iosf_sb_reg_x550(hw,
1873 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1874 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1875 if (status != IXGBE_SUCCESS)
1877 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
1878 status = ixgbe_write_iosf_sb_reg_x550(hw,
1879 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
1880 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1881 if (status != IXGBE_SUCCESS)
1884 /* Disable Flex from training TXFFE. */
1885 status = ixgbe_read_iosf_sb_reg_x550(hw,
1886 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
1887 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1888 if (status != IXGBE_SUCCESS)
1890 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
1891 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
1892 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
1893 status = ixgbe_write_iosf_sb_reg_x550(hw,
1894 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
1895 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1896 if (status != IXGBE_SUCCESS)
1898 status = ixgbe_read_iosf_sb_reg_x550(hw,
1899 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
1900 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1901 if (status != IXGBE_SUCCESS)
1903 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
1904 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
1905 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
1906 status = ixgbe_write_iosf_sb_reg_x550(hw,
1907 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
1908 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1909 if (status != IXGBE_SUCCESS)
1912 /* Enable override for coefficients. */
1913 status = ixgbe_read_iosf_sb_reg_x550(hw,
1914 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
1915 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1916 if (status != IXGBE_SUCCESS)
1918 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
1919 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
1920 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
1921 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
1922 status = ixgbe_write_iosf_sb_reg_x550(hw,
1923 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
1924 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1925 if (status != IXGBE_SUCCESS)
1928 /* Toggle port SW reset by AN reset. */
1929 status = ixgbe_read_iosf_sb_reg_x550(hw,
1930 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1931 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1932 if (status != IXGBE_SUCCESS)
1934 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1935 status = ixgbe_write_iosf_sb_reg_x550(hw,
1936 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1937 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1943 * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
1944 * @hw: address of hardware structure
1945 * @link_up: address of boolean to indicate link status
1947 * Returns error code if unable to get link status.
1949 static s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
1956 /* read this twice back to back to indicate current status */
1957 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
1958 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1960 if (ret != IXGBE_SUCCESS)
1963 ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
1964 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1966 if (ret != IXGBE_SUCCESS)
1969 *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
1971 return IXGBE_SUCCESS;
1975 * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
1976 * @hw: point to hardware structure
1978 * Configures the link between the integrated KR PHY and the external X557 PHY
1979 * The driver will call this function when it gets a link status change
1980 * interrupt from the X557 PHY. This function configures the link speed
1981 * between the PHYs to match the link speed of the BASE-T link.
1983 * A return of a non-zero value indicates an error, and the base driver should
1984 * not report link up.
1986 s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
1988 ixgbe_link_speed force_speed;
1993 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
1994 return IXGBE_ERR_CONFIG;
1996 /* If link is not up, then there is no setup necessary so return */
1997 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
1998 if (status != IXGBE_SUCCESS)
2002 return IXGBE_SUCCESS;
2004 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
2005 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2007 if (status != IXGBE_SUCCESS)
2010 /* If link is not still up, then no setup is necessary so return */
2011 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2012 if (status != IXGBE_SUCCESS)
2015 return IXGBE_SUCCESS;
2017 /* clear everything but the speed and duplex bits */
2018 speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
2021 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
2022 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
2024 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
2025 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
2028 /* Internal PHY does not support anything else */
2029 return IXGBE_ERR_INVALID_LINK_SETTINGS;
2032 return ixgbe_setup_ixfi_x550em(hw, &force_speed);
2036 * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
2037 * @hw: pointer to hardware structure
2039 * Configures the integrated KR PHY to use internal loopback mode.
2041 s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
2046 /* Disable AN and force speed to 10G Serial. */
2047 status = ixgbe_read_iosf_sb_reg_x550(hw,
2048 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2049 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2050 if (status != IXGBE_SUCCESS)
2052 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
2053 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
2054 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
2055 status = ixgbe_write_iosf_sb_reg_x550(hw,
2056 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
2057 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2058 if (status != IXGBE_SUCCESS)
2061 /* Set near-end loopback clocks. */
2062 status = ixgbe_read_iosf_sb_reg_x550(hw,
2063 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
2064 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2065 if (status != IXGBE_SUCCESS)
2067 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
2068 reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
2069 status = ixgbe_write_iosf_sb_reg_x550(hw,
2070 IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
2071 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2072 if (status != IXGBE_SUCCESS)
2075 /* Set loopback enable. */
2076 status = ixgbe_read_iosf_sb_reg_x550(hw,
2077 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
2078 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2079 if (status != IXGBE_SUCCESS)
2081 reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
2082 status = ixgbe_write_iosf_sb_reg_x550(hw,
2083 IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
2084 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2085 if (status != IXGBE_SUCCESS)
2088 /* Training bypass. */
2089 status = ixgbe_read_iosf_sb_reg_x550(hw,
2090 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2091 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2092 if (status != IXGBE_SUCCESS)
2094 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
2095 status = ixgbe_write_iosf_sb_reg_x550(hw,
2096 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
2097 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2103 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2104 * assuming that the semaphore is already obtained.
2105 * @hw: pointer to hardware structure
2106 * @offset: offset of word in the EEPROM to read
2107 * @data: word read from the EEPROM
2109 * Reads a 16 bit word from the EEPROM using the hostif.
2111 s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2115 struct ixgbe_hic_read_shadow_ram buffer;
2117 DEBUGFUNC("ixgbe_read_ee_hostif_data_X550");
2118 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2119 buffer.hdr.req.buf_lenh = 0;
2120 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2121 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2123 /* convert offset from words to bytes */
2124 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2126 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2128 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2130 IXGBE_HI_COMMAND_TIMEOUT, FALSE);
2135 *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
2136 FW_NVM_DATA_OFFSET);
2142 * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
2143 * @hw: pointer to hardware structure
2144 * @offset: offset of word in the EEPROM to read
2145 * @data: word read from the EEPROM
2147 * Reads a 16 bit word from the EEPROM using the hostif.
2149 s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2152 s32 status = IXGBE_SUCCESS;
2154 DEBUGFUNC("ixgbe_read_ee_hostif_X550");
2156 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2158 status = ixgbe_read_ee_hostif_data_X550(hw, offset, data);
2159 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2161 status = IXGBE_ERR_SWFW_SYNC;
2168 * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
2169 * @hw: pointer to hardware structure
2170 * @offset: offset of word in the EEPROM to read
2171 * @words: number of words
2172 * @data: word(s) read from the EEPROM
2174 * Reads a 16 bit word(s) from the EEPROM using the hostif.
2176 s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2177 u16 offset, u16 words, u16 *data)
2179 struct ixgbe_hic_read_shadow_ram buffer;
2180 u32 current_word = 0;
2185 DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
2187 /* Take semaphore for the entire operation. */
2188 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2190 DEBUGOUT("EEPROM read buffer - semaphore failed\n");
2194 if (words > FW_MAX_READ_BUFFER_SIZE / 2)
2195 words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
2197 words_to_read = words;
2199 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
2200 buffer.hdr.req.buf_lenh = 0;
2201 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
2202 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2204 /* convert offset from words to bytes */
2205 buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
2206 buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
2208 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2210 IXGBE_HI_COMMAND_TIMEOUT,
2214 DEBUGOUT("Host interface command failed\n");
2218 for (i = 0; i < words_to_read; i++) {
2219 u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
2221 u32 value = IXGBE_READ_REG(hw, reg);
2223 data[current_word] = (u16)(value & 0xffff);
2226 if (i < words_to_read) {
2228 data[current_word] = (u16)(value & 0xffff);
2232 words -= words_to_read;
2236 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2241 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2242 * @hw: pointer to hardware structure
2243 * @offset: offset of word in the EEPROM to write
2244 * @data: word write to the EEPROM
2246 * Write a 16 bit word to the EEPROM using the hostif.
2248 s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
2252 struct ixgbe_hic_write_shadow_ram buffer;
2254 DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
2256 buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
2257 buffer.hdr.req.buf_lenh = 0;
2258 buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
2259 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
2262 buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
2264 buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
2266 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2268 IXGBE_HI_COMMAND_TIMEOUT, FALSE);
2274 * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
2275 * @hw: pointer to hardware structure
2276 * @offset: offset of word in the EEPROM to write
2277 * @data: word write to the EEPROM
2279 * Write a 16 bit word to the EEPROM using the hostif.
2281 s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
2284 s32 status = IXGBE_SUCCESS;
2286 DEBUGFUNC("ixgbe_write_ee_hostif_X550");
2288 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
2290 status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
2291 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2293 DEBUGOUT("write ee hostif failed to get semaphore");
2294 status = IXGBE_ERR_SWFW_SYNC;
2301 * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
2302 * @hw: pointer to hardware structure
2303 * @offset: offset of word in the EEPROM to write
2304 * @words: number of words
2305 * @data: word(s) write to the EEPROM
2307 * Write a 16 bit word(s) to the EEPROM using the hostif.
2309 s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
2310 u16 offset, u16 words, u16 *data)
2312 s32 status = IXGBE_SUCCESS;
2315 DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
2317 /* Take semaphore for the entire operation. */
2318 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2319 if (status != IXGBE_SUCCESS) {
2320 DEBUGOUT("EEPROM write buffer - semaphore failed\n");
2324 for (i = 0; i < words; i++) {
2325 status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
2328 if (status != IXGBE_SUCCESS) {
2329 DEBUGOUT("Eeprom buffered write failed\n");
2334 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
2341 * ixgbe_checksum_ptr_x550 - Checksum one pointer region
2342 * @hw: pointer to hardware structure
2343 * @ptr: pointer offset in eeprom
2344 * @size: size of section pointed by ptr, if 0 first word will be used as size
2345 * @csum: address of checksum to update
2347 * Returns error status for any failure
2349 static s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
2350 u16 size, u16 *csum, u16 *buffer,
2355 u16 length, bufsz, i, start;
2358 bufsz = sizeof(buf) / sizeof(buf[0]);
2360 /* Read a chunk at the pointer location */
2362 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
2364 DEBUGOUT("Failed to read EEPROM image\n");
2369 if (buffer_size < ptr)
2370 return IXGBE_ERR_PARAM;
2371 local_buffer = &buffer[ptr];
2379 length = local_buffer[0];
2381 /* Skip pointer section if length is invalid. */
2382 if (length == 0xFFFF || length == 0 ||
2383 (ptr + length) >= hw->eeprom.word_size)
2384 return IXGBE_SUCCESS;
2387 if (buffer && ((u32)start + (u32)length > buffer_size))
2388 return IXGBE_ERR_PARAM;
2390 for (i = start; length; i++, length--) {
2391 if (i == bufsz && !buffer) {
2397 /* Read a chunk at the pointer location */
2398 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
2401 DEBUGOUT("Failed to read EEPROM image\n");
2405 *csum += local_buffer[i];
2407 return IXGBE_SUCCESS;
2411 * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
2412 * @hw: pointer to hardware structure
2413 * @buffer: pointer to buffer containing calculated checksum
2414 * @buffer_size: size of buffer
2416 * Returns a negative error code on error, or the 16-bit checksum
2418 s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
2420 u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
2424 u16 pointer, i, size;
2426 DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
2428 hw->eeprom.ops.init_params(hw);
2431 /* Read pointer area */
2432 status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
2433 IXGBE_EEPROM_LAST_WORD + 1,
2436 DEBUGOUT("Failed to read EEPROM image\n");
2439 local_buffer = eeprom_ptrs;
2441 if (buffer_size < IXGBE_EEPROM_LAST_WORD)
2442 return IXGBE_ERR_PARAM;
2443 local_buffer = buffer;
2447 * For X550 hardware include 0x0-0x41 in the checksum, skip the
2448 * checksum word itself
2450 for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
2451 if (i != IXGBE_EEPROM_CHECKSUM)
2452 checksum += local_buffer[i];
2455 * Include all data from pointers 0x3, 0x6-0xE. This excludes the
2456 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
2458 for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
2459 if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
2462 pointer = local_buffer[i];
2464 /* Skip pointer section if the pointer is invalid. */
2465 if (pointer == 0xFFFF || pointer == 0 ||
2466 pointer >= hw->eeprom.word_size)
2470 case IXGBE_PCIE_GENERAL_PTR:
2471 size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
2473 case IXGBE_PCIE_CONFIG0_PTR:
2474 case IXGBE_PCIE_CONFIG1_PTR:
2475 size = IXGBE_PCIE_CONFIG_SIZE;
2482 status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
2483 buffer, buffer_size);
2488 checksum = (u16)IXGBE_EEPROM_SUM - checksum;
2490 return (s32)checksum;
2494 * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
2495 * @hw: pointer to hardware structure
2497 * Returns a negative error code on error, or the 16-bit checksum
2499 s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
2501 return ixgbe_calc_checksum_X550(hw, NULL, 0);
2505 * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
2506 * @hw: pointer to hardware structure
2507 * @checksum_val: calculated checksum
2509 * Performs checksum calculation and validates the EEPROM checksum. If the
2510 * caller does not need checksum_val, the value can be NULL.
2512 s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
2516 u16 read_checksum = 0;
2518 DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
2520 /* Read the first word from the EEPROM. If this times out or fails, do
2521 * not continue or we could be in for a very long wait while every
2524 status = hw->eeprom.ops.read(hw, 0, &checksum);
2526 DEBUGOUT("EEPROM read failed\n");
2530 status = hw->eeprom.ops.calc_checksum(hw);
2534 checksum = (u16)(status & 0xffff);
2536 status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
2541 /* Verify read checksum from EEPROM is the same as
2542 * calculated checksum
2544 if (read_checksum != checksum) {
2545 status = IXGBE_ERR_EEPROM_CHECKSUM;
2546 ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
2547 "Invalid EEPROM checksum");
2550 /* If the user cares, return the calculated checksum */
2552 *checksum_val = checksum;
2558 * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
2559 * @hw: pointer to hardware structure
2561 * After writing EEPROM to shadow RAM using EEWR register, software calculates
2562 * checksum and updates the EEPROM and instructs the hardware to update
2565 s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
2570 DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
2572 /* Read the first word from the EEPROM. If this times out or fails, do
2573 * not continue or we could be in for a very long wait while every
2576 status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
2578 DEBUGOUT("EEPROM read failed\n");
2582 status = ixgbe_calc_eeprom_checksum_X550(hw);
2586 checksum = (u16)(status & 0xffff);
2588 status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
2593 status = ixgbe_update_flash_X550(hw);
2599 * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
2600 * @hw: pointer to hardware structure
2602 * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
2604 s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
2606 s32 status = IXGBE_SUCCESS;
2607 union ixgbe_hic_hdr2 buffer;
2609 DEBUGFUNC("ixgbe_update_flash_X550");
2611 buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
2612 buffer.req.buf_lenh = 0;
2613 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
2614 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
2616 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
2618 IXGBE_HI_COMMAND_TIMEOUT, FALSE);
2624 * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
2625 * @hw: pointer to hardware structure
2627 * Determines physical layer capabilities of the current configuration.
2629 u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
2631 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
2632 u16 ext_ability = 0;
2634 DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
2636 hw->phy.ops.identify(hw);
2638 switch (hw->phy.type) {
2639 case ixgbe_phy_x550em_kr:
2640 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
2641 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2643 case ixgbe_phy_x550em_kx4:
2644 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
2645 IXGBE_PHYSICAL_LAYER_1000BASE_KX;
2647 case ixgbe_phy_x550em_ext_t:
2648 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
2649 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
2651 if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
2652 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
2653 if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
2654 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
2660 if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
2661 physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
2663 return physical_layer;
2667 * ixgbe_get_bus_info_x550em - Set PCI bus info
2668 * @hw: pointer to hardware structure
2670 * Sets bus link width and speed to unknown because X550em is
2673 s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
2676 DEBUGFUNC("ixgbe_get_bus_info_x550em");
2678 hw->bus.width = ixgbe_bus_width_unknown;
2679 hw->bus.speed = ixgbe_bus_speed_unknown;
2681 hw->mac.ops.set_lan_id(hw);
2683 return IXGBE_SUCCESS;
2687 * ixgbe_disable_rx_x550 - Disable RX unit
2689 * Enables the Rx DMA unit for x550
2691 void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
2693 u32 rxctrl, pfdtxgswc;
2695 struct ixgbe_hic_disable_rxen fw_cmd;
2697 DEBUGFUNC("ixgbe_enable_rx_dma_x550");
2699 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
2700 if (rxctrl & IXGBE_RXCTRL_RXEN) {
2701 pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
2702 if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
2703 pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
2704 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
2705 hw->mac.set_lben = TRUE;
2707 hw->mac.set_lben = FALSE;
2710 fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
2711 fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
2712 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
2713 fw_cmd.port_number = (u8)hw->bus.lan_id;
2715 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
2716 sizeof(struct ixgbe_hic_disable_rxen),
2717 IXGBE_HI_COMMAND_TIMEOUT, TRUE);
2719 /* If we fail - disable RX using register write */
2721 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
2722 if (rxctrl & IXGBE_RXCTRL_RXEN) {
2723 rxctrl &= ~IXGBE_RXCTRL_RXEN;
2724 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
2731 * ixgbe_enter_lplu_x550em - Transition to low power states
2732 * @hw: pointer to hardware structure
2734 * Configures Low Power Link Up on transition to low power states
2735 * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
2736 * X557 PHY immediately prior to entering LPLU.
2738 s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
2740 u16 an_10g_cntl_reg, autoneg_reg, speed;
2742 ixgbe_link_speed lcd_speed;
2746 /* If blocked by MNG FW, then don't restart AN */
2747 if (ixgbe_check_reset_blocked(hw))
2748 return IXGBE_SUCCESS;
2750 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2751 if (status != IXGBE_SUCCESS)
2754 status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
2756 if (status != IXGBE_SUCCESS)
2759 /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
2760 * disabled, then force link down by entering low power mode.
2762 if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
2763 !(hw->wol_enabled || ixgbe_mng_present(hw)))
2764 return ixgbe_set_copper_phy_power(hw, FALSE);
2767 status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
2769 if (status != IXGBE_SUCCESS)
2772 /* If no valid LCD link speed, then force link down and exit. */
2773 if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
2774 return ixgbe_set_copper_phy_power(hw, FALSE);
2776 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
2777 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2780 if (status != IXGBE_SUCCESS)
2783 /* If no link now, speed is invalid so take link down */
2784 status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
2785 if (status != IXGBE_SUCCESS)
2786 return ixgbe_set_copper_phy_power(hw, FALSE);
2788 /* clear everything but the speed bits */
2789 speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
2791 /* If current speed is already LCD, then exit. */
2792 if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
2793 (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
2794 ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
2795 (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
2798 /* Clear AN completed indication */
2799 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
2800 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2803 if (status != IXGBE_SUCCESS)
2806 status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
2807 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2810 if (status != IXGBE_SUCCESS)
2813 status = hw->phy.ops.read_reg(hw,
2814 IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
2815 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2818 if (status != IXGBE_SUCCESS)
2821 save_autoneg = hw->phy.autoneg_advertised;
2823 /* Setup link at least common link speed */
2824 status = hw->mac.ops.setup_link(hw, lcd_speed, FALSE);
2826 /* restore autoneg from before setting lplu speed */
2827 hw->phy.autoneg_advertised = save_autoneg;
2833 * ixgbe_get_lcd_x550em - Determine lowest common denominator
2834 * @hw: pointer to hardware structure
2835 * @lcd_speed: pointer to lowest common link speed
2837 * Determine lowest common link speed with link partner.
2839 s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
2843 u16 word = hw->eeprom.ctrl_word_3;
2845 *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
2847 status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
2848 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
2851 if (status != IXGBE_SUCCESS)
2854 /* If link partner advertised 1G, return 1G */
2855 if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
2856 *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
2860 /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
2861 if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
2862 (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
2865 /* Link partner not capable of lower speeds, return 10G */
2866 *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
2871 * ixgbe_setup_fc_X550em - Set up flow control
2872 * @hw: pointer to hardware structure
2874 * Called at init time to set up flow control.
2876 s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
2878 s32 ret_val = IXGBE_SUCCESS;
2879 u32 pause, asm_dir, reg_val;
2881 DEBUGFUNC("ixgbe_setup_fc_X550em");
2883 /* Validate the requested mode */
2884 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
2885 ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
2886 "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
2887 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
2891 /* 10gig parts do not have a word in the EEPROM to determine the
2892 * default flow control setting, so we explicitly set it to full.
2894 if (hw->fc.requested_mode == ixgbe_fc_default)
2895 hw->fc.requested_mode = ixgbe_fc_full;
2897 /* Determine PAUSE and ASM_DIR bits. */
2898 switch (hw->fc.requested_mode) {
2903 case ixgbe_fc_tx_pause:
2907 case ixgbe_fc_rx_pause:
2908 /* Rx Flow control is enabled and Tx Flow control is
2909 * disabled by software override. Since there really
2910 * isn't a way to advertise that we are capable of RX
2911 * Pause ONLY, we will advertise that we support both
2912 * symmetric and asymmetric Rx PAUSE, as such we fall
2913 * through to the fc_full statement. Later, we will
2914 * disable the adapter's ability to send PAUSE frames.
2921 ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
2922 "Flow control param set incorrectly\n");
2923 ret_val = IXGBE_ERR_CONFIG;
2927 if (hw->phy.media_type == ixgbe_media_type_backplane) {
2928 ret_val = ixgbe_read_iosf_sb_reg_x550(hw,
2929 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
2930 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
2931 if (ret_val != IXGBE_SUCCESS)
2933 reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
2934 IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
2936 reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
2938 reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
2939 ret_val = ixgbe_write_iosf_sb_reg_x550(hw,
2940 IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
2941 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
2943 /* Not all devices fully support AN. */
2944 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR)
2945 hw->fc.disable_fc_autoneg = TRUE;
2953 * ixgbe_set_mux - Set mux for port 1 access with CS4227
2954 * @hw: pointer to hardware structure
2955 * @state: set mux if 1, clear if 0
2957 static void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
2961 if (!hw->bus.lan_id)
2963 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
2965 esdp |= IXGBE_ESDP_SDP1;
2967 esdp &= ~IXGBE_ESDP_SDP1;
2968 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
2969 IXGBE_WRITE_FLUSH(hw);
2973 * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
2974 * @hw: pointer to hardware structure
2975 * @mask: Mask to specify which semaphore to acquire
2977 * Acquires the SWFW semaphore and sets the I2C MUX
2979 s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
2983 DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
2985 status = ixgbe_acquire_swfw_sync_X540(hw, mask);
2989 if (mask & IXGBE_GSSR_I2C_MASK)
2990 ixgbe_set_mux(hw, 1);
2992 return IXGBE_SUCCESS;
2996 * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
2997 * @hw: pointer to hardware structure
2998 * @mask: Mask to specify which semaphore to release
3000 * Releases the SWFW semaphore and sets the I2C MUX
3002 void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
3004 DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
3006 if (mask & IXGBE_GSSR_I2C_MASK)
3007 ixgbe_set_mux(hw, 0);
3009 ixgbe_release_swfw_sync_X540(hw, mask);
3013 * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
3014 * @hw: pointer to hardware structure
3016 * Handle external Base T PHY interrupt. If high temperature
3017 * failure alarm then return error, else if link status change
3018 * then setup internal/external PHY link
3020 * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
3021 * failure alarm, else return PHY access status.
3023 s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
3028 status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
3030 if (status != IXGBE_SUCCESS)
3034 return ixgbe_setup_internal_phy(hw);
3036 return IXGBE_SUCCESS;
3040 * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
3041 * @hw: pointer to hardware structure
3042 * @speed: new link speed
3043 * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
3045 * Setup internal/external PHY link speed based on link speed, then set
3046 * external PHY auto advertised link speed.
3048 * Returns error status for any failure
3050 s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
3051 ixgbe_link_speed speed,
3052 bool autoneg_wait_to_complete)
3055 ixgbe_link_speed force_speed;
3057 DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
3059 /* Setup internal/external PHY link speed to iXFI (10G), unless
3060 * only 1G is auto advertised then setup KX link.
3062 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
3063 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
3065 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
3067 /* If internal link mode is XFI, then setup XFI internal link. */
3068 if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
3069 status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
3071 if (status != IXGBE_SUCCESS)
3075 return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
3079 * ixgbe_check_link_t_X550em - Determine link and speed status
3080 * @hw: pointer to hardware structure
3081 * @speed: pointer to link speed
3082 * @link_up: TRUE when link is up
3083 * @link_up_wait_to_complete: bool used to wait for link up or not
3085 * Check that both the MAC and X557 external PHY have link.
3087 s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
3088 bool *link_up, bool link_up_wait_to_complete)
3093 if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
3094 return IXGBE_ERR_CONFIG;
3096 status = ixgbe_check_mac_link_generic(hw, speed, link_up,
3097 link_up_wait_to_complete);
3099 /* If check link fails or MAC link is not up, then return */
3100 if (status != IXGBE_SUCCESS || !(*link_up))
3103 /* MAC link is up, so check external PHY link.
3104 * Read this twice back to back to indicate current status.
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 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
3114 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
3117 if (status != IXGBE_SUCCESS)
3120 /* If external PHY link is not up, then indicate link not up */
3121 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
3124 return IXGBE_SUCCESS;
3128 * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
3129 * @hw: pointer to hardware structure
3131 s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
3135 status = ixgbe_reset_phy_generic(hw);
3137 if (status != IXGBE_SUCCESS)
3140 /* Configure Link Status Alarm and Temperature Threshold interrupts */
3141 return ixgbe_enable_lasi_ext_t_x550em(hw);
3145 * ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
3146 * @hw: pointer to hardware structure
3147 * @led_idx: led number to turn on
3149 s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
3153 DEBUGFUNC("ixgbe_led_on_t_X550em");
3155 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
3156 return IXGBE_ERR_PARAM;
3158 /* To turn on the LED, set mode to ON. */
3159 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3160 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
3161 phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
3162 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3163 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
3165 return IXGBE_SUCCESS;
3169 * ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
3170 * @hw: pointer to hardware structure
3171 * @led_idx: led number to turn off
3173 s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
3177 DEBUGFUNC("ixgbe_led_off_t_X550em");
3179 if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
3180 return IXGBE_ERR_PARAM;
3182 /* To turn on the LED, set mode to ON. */
3183 ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3184 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
3185 phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
3186 ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
3187 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
3189 return IXGBE_SUCCESS;