1 /*******************************************************************************
3 * Intel 10 Gigabit PCI Express Linux driver
4 * Copyright(c) 1999 - 2014 Intel Corporation.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * The full GNU General Public License is included in this distribution in
16 * the file called "COPYING".
18 * Contact Information:
19 * Linux NICS <linux.nics@intel.com>
20 * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
21 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
23 ******************************************************************************/
24 #include "ixgbe_x540.h"
25 #include "ixgbe_type.h"
26 #include "ixgbe_common.h"
27 #include "ixgbe_phy.h"
29 /** ixgbe_identify_phy_x550em - Get PHY type based on device id
30 * @hw: pointer to hardware structure
34 static s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
36 u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
38 switch (hw->device_id) {
39 case IXGBE_DEV_ID_X550EM_X_SFP:
40 /* set up for CS4227 usage */
41 hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
43 esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
44 esdp |= IXGBE_ESDP_SDP1_DIR;
46 esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
47 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
49 return ixgbe_identify_module_generic(hw);
50 case IXGBE_DEV_ID_X550EM_X_KX4:
51 hw->phy.type = ixgbe_phy_x550em_kx4;
53 case IXGBE_DEV_ID_X550EM_X_KR:
54 hw->phy.type = ixgbe_phy_x550em_kr;
56 case IXGBE_DEV_ID_X550EM_X_1G_T:
57 case IXGBE_DEV_ID_X550EM_X_10G_T:
58 return ixgbe_identify_phy_generic(hw);
65 static s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
66 u32 device_type, u16 *phy_data)
68 return IXGBE_NOT_IMPLEMENTED;
71 static s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
72 u32 device_type, u16 phy_data)
74 return IXGBE_NOT_IMPLEMENTED;
77 /** ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
78 * @hw: pointer to hardware structure
80 * Initializes the EEPROM parameters ixgbe_eeprom_info within the
81 * ixgbe_hw struct in order to set up EEPROM access.
83 static s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
85 struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
89 if (eeprom->type == ixgbe_eeprom_uninitialized) {
90 eeprom->semaphore_delay = 10;
91 eeprom->type = ixgbe_flash;
93 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
94 eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
95 IXGBE_EEC_SIZE_SHIFT);
96 eeprom->word_size = 1 << (eeprom_size +
97 IXGBE_EEPROM_WORD_SIZE_SHIFT);
99 hw_dbg(hw, "Eeprom params: type = %d, size = %d\n",
100 eeprom->type, eeprom->word_size);
106 /** ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the
108 * @hw: pointer to hardware structure
109 * @reg_addr: 32 bit PHY register to write
110 * @device_type: 3 bit device type
111 * @phy_data: Pointer to read data from the register
113 static s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
114 u32 device_type, u32 *data)
116 u32 i, command, error;
118 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
119 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
121 /* Write IOSF control register */
122 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
124 /* Check every 10 usec to see if the address cycle completed.
125 * The SB IOSF BUSY bit will clear when the operation is
128 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
129 usleep_range(10, 20);
131 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
132 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
136 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
137 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
138 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
139 hw_dbg(hw, "Failed to read, error %x\n", error);
140 return IXGBE_ERR_PHY;
143 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
144 hw_dbg(hw, "Read timed out\n");
145 return IXGBE_ERR_PHY;
148 *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
153 /** ixgbe_read_ee_hostif_data_X550 - Read EEPROM word using a host interface
154 * command assuming that the semaphore is already obtained.
155 * @hw: pointer to hardware structure
156 * @offset: offset of word in the EEPROM to read
157 * @data: word read from the EEPROM
159 * Reads a 16 bit word from the EEPROM using the hostif.
161 static s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
165 struct ixgbe_hic_read_shadow_ram buffer;
167 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
168 buffer.hdr.req.buf_lenh = 0;
169 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
170 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
172 /* convert offset from words to bytes */
173 buffer.address = cpu_to_be32(offset * 2);
175 buffer.length = cpu_to_be16(sizeof(u16));
177 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
179 IXGBE_HI_COMMAND_TIMEOUT, false);
183 *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
189 /** ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
190 * @hw: pointer to hardware structure
191 * @offset: offset of word in the EEPROM to read
192 * @words: number of words
193 * @data: word(s) read from the EEPROM
195 * Reads a 16 bit word(s) from the EEPROM using the hostif.
197 static s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
198 u16 offset, u16 words, u16 *data)
200 struct ixgbe_hic_read_shadow_ram buffer;
201 u32 current_word = 0;
206 /* Take semaphore for the entire operation. */
207 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
209 hw_dbg(hw, "EEPROM read buffer - semaphore failed\n");
214 if (words > FW_MAX_READ_BUFFER_SIZE / 2)
215 words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
217 words_to_read = words;
219 buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
220 buffer.hdr.req.buf_lenh = 0;
221 buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
222 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
224 /* convert offset from words to bytes */
225 buffer.address = cpu_to_be32((offset + current_word) * 2);
226 buffer.length = cpu_to_be16(words_to_read * 2);
228 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
230 IXGBE_HI_COMMAND_TIMEOUT,
233 hw_dbg(hw, "Host interface command failed\n");
237 for (i = 0; i < words_to_read; i++) {
238 u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
240 u32 value = IXGBE_READ_REG(hw, reg);
242 data[current_word] = (u16)(value & 0xffff);
245 if (i < words_to_read) {
247 data[current_word] = (u16)(value & 0xffff);
251 words -= words_to_read;
255 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
259 /** ixgbe_checksum_ptr_x550 - Checksum one pointer region
260 * @hw: pointer to hardware structure
261 * @ptr: pointer offset in eeprom
262 * @size: size of section pointed by ptr, if 0 first word will be used as size
263 * @csum: address of checksum to update
265 * Returns error status for any failure
267 static s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
268 u16 size, u16 *csum, u16 *buffer,
273 u16 length, bufsz, i, start;
276 bufsz = sizeof(buf) / sizeof(buf[0]);
278 /* Read a chunk at the pointer location */
280 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
282 hw_dbg(hw, "Failed to read EEPROM image\n");
287 if (buffer_size < ptr)
288 return IXGBE_ERR_PARAM;
289 local_buffer = &buffer[ptr];
297 length = local_buffer[0];
299 /* Skip pointer section if length is invalid. */
300 if (length == 0xFFFF || length == 0 ||
301 (ptr + length) >= hw->eeprom.word_size)
305 if (buffer && ((u32)start + (u32)length > buffer_size))
306 return IXGBE_ERR_PARAM;
308 for (i = start; length; i++, length--) {
309 if (i == bufsz && !buffer) {
315 /* Read a chunk at the pointer location */
316 status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
319 hw_dbg(hw, "Failed to read EEPROM image\n");
323 *csum += local_buffer[i];
328 /** ixgbe_calc_checksum_X550 - Calculates and returns the checksum
329 * @hw: pointer to hardware structure
330 * @buffer: pointer to buffer containing calculated checksum
331 * @buffer_size: size of buffer
333 * Returns a negative error code on error, or the 16-bit checksum
335 static s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer,
338 u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
342 u16 pointer, i, size;
344 hw->eeprom.ops.init_params(hw);
347 /* Read pointer area */
348 status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
349 IXGBE_EEPROM_LAST_WORD + 1,
352 hw_dbg(hw, "Failed to read EEPROM image\n");
355 local_buffer = eeprom_ptrs;
357 if (buffer_size < IXGBE_EEPROM_LAST_WORD)
358 return IXGBE_ERR_PARAM;
359 local_buffer = buffer;
362 /* For X550 hardware include 0x0-0x41 in the checksum, skip the
363 * checksum word itself
365 for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
366 if (i != IXGBE_EEPROM_CHECKSUM)
367 checksum += local_buffer[i];
369 /* Include all data from pointers 0x3, 0x6-0xE. This excludes the
370 * FW, PHY module, and PCIe Expansion/Option ROM pointers.
372 for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
373 if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
376 pointer = local_buffer[i];
378 /* Skip pointer section if the pointer is invalid. */
379 if (pointer == 0xFFFF || pointer == 0 ||
380 pointer >= hw->eeprom.word_size)
384 case IXGBE_PCIE_GENERAL_PTR:
385 size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
387 case IXGBE_PCIE_CONFIG0_PTR:
388 case IXGBE_PCIE_CONFIG1_PTR:
389 size = IXGBE_PCIE_CONFIG_SIZE;
396 status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
397 buffer, buffer_size);
402 checksum = (u16)IXGBE_EEPROM_SUM - checksum;
404 return (s32)checksum;
407 /** ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
408 * @hw: pointer to hardware structure
410 * Returns a negative error code on error, or the 16-bit checksum
412 static s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
414 return ixgbe_calc_checksum_X550(hw, NULL, 0);
417 /** ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
418 * @hw: pointer to hardware structure
419 * @offset: offset of word in the EEPROM to read
420 * @data: word read from the EEPROM
422 * Reads a 16 bit word from the EEPROM using the hostif.
424 static s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 *data)
428 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) == 0) {
429 status = ixgbe_read_ee_hostif_data_X550(hw, offset, data);
430 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
432 status = IXGBE_ERR_SWFW_SYNC;
438 /** ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
439 * @hw: pointer to hardware structure
440 * @checksum_val: calculated checksum
442 * Performs checksum calculation and validates the EEPROM checksum. If the
443 * caller does not need checksum_val, the value can be NULL.
445 static s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw,
450 u16 read_checksum = 0;
452 /* Read the first word from the EEPROM. If this times out or fails, do
453 * not continue or we could be in for a very long wait while every
456 status = hw->eeprom.ops.read(hw, 0, &checksum);
458 hw_dbg(hw, "EEPROM read failed\n");
462 status = hw->eeprom.ops.calc_checksum(hw);
466 checksum = (u16)(status & 0xffff);
468 status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
473 /* Verify read checksum from EEPROM is the same as
474 * calculated checksum
476 if (read_checksum != checksum) {
477 status = IXGBE_ERR_EEPROM_CHECKSUM;
478 hw_dbg(hw, "Invalid EEPROM checksum");
481 /* If the user cares, return the calculated checksum */
483 *checksum_val = checksum;
488 /** ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
489 * @hw: pointer to hardware structure
490 * @offset: offset of word in the EEPROM to write
491 * @data: word write to the EEPROM
493 * Write a 16 bit word to the EEPROM using the hostif.
495 static s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
499 struct ixgbe_hic_write_shadow_ram buffer;
501 buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
502 buffer.hdr.req.buf_lenh = 0;
503 buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
504 buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
507 buffer.length = cpu_to_be16(sizeof(u16));
509 buffer.address = cpu_to_be32(offset * 2);
511 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
513 IXGBE_HI_COMMAND_TIMEOUT, false);
517 /** ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
518 * @hw: pointer to hardware structure
519 * @offset: offset of word in the EEPROM to write
520 * @data: word write to the EEPROM
522 * Write a 16 bit word to the EEPROM using the hostif.
524 static s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset, u16 data)
528 if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) == 0) {
529 status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
530 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
532 hw_dbg(hw, "write ee hostif failed to get semaphore");
533 status = IXGBE_ERR_SWFW_SYNC;
539 /** ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
540 * @hw: pointer to hardware structure
542 * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
544 static s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
547 union ixgbe_hic_hdr2 buffer;
549 buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
550 buffer.req.buf_lenh = 0;
551 buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
552 buffer.req.checksum = FW_DEFAULT_CHECKSUM;
554 status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
556 IXGBE_HI_COMMAND_TIMEOUT, false);
560 /** ixgbe_disable_rx_x550 - Disable RX unit
562 * Enables the Rx DMA unit for x550
564 static void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
566 u32 rxctrl, pfdtxgswc;
568 struct ixgbe_hic_disable_rxen fw_cmd;
570 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
571 if (rxctrl & IXGBE_RXCTRL_RXEN) {
572 pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
573 if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
574 pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
575 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
576 hw->mac.set_lben = true;
578 hw->mac.set_lben = false;
581 fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
582 fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
583 fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
584 fw_cmd.port_number = (u8)hw->bus.lan_id;
586 status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
587 sizeof(struct ixgbe_hic_disable_rxen),
588 IXGBE_HI_COMMAND_TIMEOUT, true);
590 /* If we fail - disable RX using register write */
592 rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
593 if (rxctrl & IXGBE_RXCTRL_RXEN) {
594 rxctrl &= ~IXGBE_RXCTRL_RXEN;
595 IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
601 /** ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
602 * @hw: pointer to hardware structure
604 * After writing EEPROM to shadow RAM using EEWR register, software calculates
605 * checksum and updates the EEPROM and instructs the hardware to update
608 static s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
613 /* Read the first word from the EEPROM. If this times out or fails, do
614 * not continue or we could be in for a very long wait while every
617 status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
619 hw_dbg(hw, "EEPROM read failed\n");
623 status = ixgbe_calc_eeprom_checksum_X550(hw);
627 checksum = (u16)(status & 0xffff);
629 status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
634 status = ixgbe_update_flash_X550(hw);
639 /** ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
640 * @hw: pointer to hardware structure
641 * @offset: offset of word in the EEPROM to write
642 * @words: number of words
643 * @data: word(s) write to the EEPROM
646 * Write a 16 bit word(s) to the EEPROM using the hostif.
648 static s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
649 u16 offset, u16 words,
655 /* Take semaphore for the entire operation. */
656 status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
658 hw_dbg(hw, "EEPROM write buffer - semaphore failed\n");
662 for (i = 0; i < words; i++) {
663 status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
666 hw_dbg(hw, "Eeprom buffered write failed\n");
671 hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
676 /** ixgbe_init_mac_link_ops_X550em - init mac link function pointers
677 * @hw: pointer to hardware structure
679 static void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
681 struct ixgbe_mac_info *mac = &hw->mac;
683 /* CS4227 does not support autoneg, so disable the laser control
684 * functions for SFP+ fiber
686 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP) {
687 mac->ops.disable_tx_laser = NULL;
688 mac->ops.enable_tx_laser = NULL;
689 mac->ops.flap_tx_laser = NULL;
693 /** ixgbe_setup_sfp_modules_X550em - Setup SFP module
694 * @hw: pointer to hardware structure
696 static s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
699 u16 reg_slice, edc_mode;
702 switch (hw->phy.sfp_type) {
703 case ixgbe_sfp_type_unknown:
705 case ixgbe_sfp_type_not_present:
706 return IXGBE_ERR_SFP_NOT_PRESENT;
707 case ixgbe_sfp_type_da_cu_core0:
708 case ixgbe_sfp_type_da_cu_core1:
711 case ixgbe_sfp_type_srlr_core0:
712 case ixgbe_sfp_type_srlr_core1:
713 case ixgbe_sfp_type_da_act_lmt_core0:
714 case ixgbe_sfp_type_da_act_lmt_core1:
715 case ixgbe_sfp_type_1g_sx_core0:
716 case ixgbe_sfp_type_1g_sx_core1:
717 setup_linear = false;
720 return IXGBE_ERR_SFP_NOT_SUPPORTED;
723 ixgbe_init_mac_link_ops_X550em(hw);
724 hw->phy.ops.reset = NULL;
726 /* The CS4227 slice address is the base address + the port-pair reg
727 * offset. I.e. Slice 0 = 0x12B0 and slice 1 = 0x22B0.
729 reg_slice = IXGBE_CS4227_SPARE24_LSB + (hw->bus.lan_id << 12);
732 edc_mode = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
734 edc_mode = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
736 /* Configure CS4227 for connection type. */
737 ret_val = hw->phy.ops.write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
741 ret_val = hw->phy.ops.write_i2c_combined(hw, 0x80, reg_slice,
747 /** ixgbe_get_link_capabilities_x550em - Determines link capabilities
748 * @hw: pointer to hardware structure
749 * @speed: pointer to link speed
750 * @autoneg: true when autoneg or autotry is enabled
752 static s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
753 ixgbe_link_speed *speed,
757 if (hw->phy.media_type == ixgbe_media_type_fiber) {
758 /* CS4227 SFP must not enable auto-negotiation */
761 if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
762 hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
763 *speed = IXGBE_LINK_SPEED_1GB_FULL;
767 /* Link capabilities are based on SFP */
768 if (hw->phy.multispeed_fiber)
769 *speed = IXGBE_LINK_SPEED_10GB_FULL |
770 IXGBE_LINK_SPEED_1GB_FULL;
772 *speed = IXGBE_LINK_SPEED_10GB_FULL;
774 *speed = IXGBE_LINK_SPEED_10GB_FULL |
775 IXGBE_LINK_SPEED_1GB_FULL;
781 /** ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the
784 * @hw: pointer to hardware structure
785 * @reg_addr: 32 bit PHY register to write
786 * @device_type: 3 bit device type
787 * @data: Data to write to the register
789 static s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
790 u32 device_type, u32 data)
792 u32 i, command, error;
794 command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
795 (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
797 /* Write IOSF control register */
798 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
800 /* Write IOSF data register */
801 IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
803 /* Check every 10 usec to see if the address cycle completed.
804 * The SB IOSF BUSY bit will clear when the operation is
807 for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
808 usleep_range(10, 20);
810 command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
811 if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
815 if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
816 error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
817 IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
818 hw_dbg(hw, "Failed to write, error %x\n", error);
819 return IXGBE_ERR_PHY;
822 if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
823 hw_dbg(hw, "Write timed out\n");
824 return IXGBE_ERR_PHY;
830 /** ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
831 * @hw: pointer to hardware structure
832 * @speed: the link speed to force
834 * Configures the integrated KR PHY to use iXFI mode. Used to connect an
835 * internal and external PHY at a specific speed, without autonegotiation.
837 static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
842 /* Disable AN and force speed to 10G Serial. */
843 status = ixgbe_read_iosf_sb_reg_x550(hw,
844 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
845 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
849 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
850 reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
852 /* Select forced link speed for internal PHY. */
854 case IXGBE_LINK_SPEED_10GB_FULL:
855 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
857 case IXGBE_LINK_SPEED_1GB_FULL:
858 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
861 /* Other link speeds are not supported by internal KR PHY. */
862 return IXGBE_ERR_LINK_SETUP;
865 status = ixgbe_write_iosf_sb_reg_x550(hw,
866 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
867 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
871 /* Disable training protocol FSM. */
872 status = ixgbe_read_iosf_sb_reg_x550(hw,
873 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
874 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
878 reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
879 status = ixgbe_write_iosf_sb_reg_x550(hw,
880 IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
881 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
885 /* Disable Flex from training TXFFE. */
886 status = ixgbe_read_iosf_sb_reg_x550(hw,
887 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
888 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
892 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
893 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
894 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
895 status = ixgbe_write_iosf_sb_reg_x550(hw,
896 IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
897 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
901 status = ixgbe_read_iosf_sb_reg_x550(hw,
902 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
903 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
907 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
908 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
909 reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
910 status = ixgbe_write_iosf_sb_reg_x550(hw,
911 IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
912 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
916 /* Enable override for coefficients. */
917 status = ixgbe_read_iosf_sb_reg_x550(hw,
918 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
919 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
923 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
924 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
925 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
926 reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
927 status = ixgbe_write_iosf_sb_reg_x550(hw,
928 IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
929 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
933 /* Toggle port SW reset by AN reset. */
934 status = ixgbe_read_iosf_sb_reg_x550(hw,
935 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
936 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
940 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
941 status = ixgbe_write_iosf_sb_reg_x550(hw,
942 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
943 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
948 /** ixgbe_setup_kx4_x550em - Configure the KX4 PHY.
949 * @hw: pointer to hardware structure
951 * Configures the integrated KX4 PHY.
953 static s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw)
958 status = ixgbe_read_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
959 IXGBE_SB_IOSF_TARGET_KX4_PCS0 +
960 hw->bus.lan_id, ®_val);
964 reg_val &= ~(IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4 |
965 IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX);
967 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_ENABLE;
969 /* Advertise 10G support. */
970 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
971 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4;
973 /* Advertise 1G support. */
974 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
975 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX;
977 /* Restart auto-negotiation. */
978 reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_RESTART;
979 status = ixgbe_write_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
980 IXGBE_SB_IOSF_TARGET_KX4_PCS0 +
981 hw->bus.lan_id, reg_val);
986 /** ixgbe_setup_kr_x550em - Configure the KR PHY.
987 * @hw: pointer to hardware structure
989 * Configures the integrated KR PHY.
991 static s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
996 status = ixgbe_read_iosf_sb_reg_x550(hw,
997 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
998 IXGBE_SB_IOSF_TARGET_KR_PHY, ®_val);
1002 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
1003 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ;
1004 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
1005 reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
1006 IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
1008 /* Advertise 10G support. */
1009 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
1010 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
1012 /* Advertise 1G support. */
1013 if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
1014 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
1016 /* Restart auto-negotiation. */
1017 reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
1018 status = ixgbe_write_iosf_sb_reg_x550(hw,
1019 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
1020 IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
1025 /** ixgbe_setup_internal_phy_x550em - Configure integrated KR PHY
1026 * @hw: point to hardware structure
1028 * Configures the integrated KR PHY to talk to the external PHY. The base
1029 * driver will call this function when it gets notification via interrupt from
1030 * the external PHY. This function forces the internal PHY into iXFI mode at
1031 * the correct speed.
1033 * A return of a non-zero value indicates an error, and the base driver should
1034 * not report link up.
1036 static s32 ixgbe_setup_internal_phy_x550em(struct ixgbe_hw *hw)
1039 u16 lasi, autoneg_status, speed;
1040 ixgbe_link_speed force_speed;
1042 /* Verify that the external link status has changed */
1043 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_XENPAK_LASI_STATUS,
1044 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &lasi);
1048 /* If there was no change in link status, we can just exit */
1049 if (!(lasi & IXGBE_XENPAK_LASI_LINK_STATUS_ALARM))
1052 /* we read this twice back to back to indicate current status */
1053 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
1054 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1059 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
1060 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1065 /* If link is not up return an error indicating treat link as down */
1066 if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
1067 return IXGBE_ERR_INVALID_LINK_SETTINGS;
1069 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
1070 IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
1073 /* clear everything but the speed and duplex bits */
1074 speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
1077 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
1078 force_speed = IXGBE_LINK_SPEED_10GB_FULL;
1080 case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
1081 force_speed = IXGBE_LINK_SPEED_1GB_FULL;
1084 /* Internal PHY does not support anything else */
1085 return IXGBE_ERR_INVALID_LINK_SETTINGS;
1088 return ixgbe_setup_ixfi_x550em(hw, &force_speed);
1091 /** ixgbe_init_phy_ops_X550em - PHY/SFP specific init
1092 * @hw: pointer to hardware structure
1094 * Initialize any function pointers that were not able to be
1095 * set during init_shared_code because the PHY/SFP type was
1096 * not known. Perform the SFP init if necessary.
1098 static s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
1100 struct ixgbe_phy_info *phy = &hw->phy;
1104 if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP) {
1105 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
1106 phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
1108 if (hw->bus.lan_id) {
1109 esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
1110 esdp |= IXGBE_ESDP_SDP1_DIR;
1112 esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
1113 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
1116 /* Identify the PHY or SFP module */
1117 ret_val = phy->ops.identify(hw);
1119 /* Setup function pointers based on detected SFP module and speeds */
1120 ixgbe_init_mac_link_ops_X550em(hw);
1121 if (phy->sfp_type != ixgbe_sfp_type_unknown)
1122 phy->ops.reset = NULL;
1124 /* Set functions pointers based on phy type */
1125 switch (hw->phy.type) {
1126 case ixgbe_phy_x550em_kx4:
1127 phy->ops.setup_link = ixgbe_setup_kx4_x550em;
1128 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1129 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1131 case ixgbe_phy_x550em_kr:
1132 phy->ops.setup_link = ixgbe_setup_kr_x550em;
1133 phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
1134 phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
1136 case ixgbe_phy_x550em_ext_t:
1137 phy->ops.setup_internal_link = ixgbe_setup_internal_phy_x550em;
1145 /** ixgbe_get_media_type_X550em - Get media type
1146 * @hw: pointer to hardware structure
1148 * Returns the media type (fiber, copper, backplane)
1151 static enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
1153 enum ixgbe_media_type media_type;
1155 /* Detect if there is a copper PHY attached. */
1156 switch (hw->device_id) {
1157 case IXGBE_DEV_ID_X550EM_X_KR:
1158 case IXGBE_DEV_ID_X550EM_X_KX4:
1159 media_type = ixgbe_media_type_backplane;
1161 case IXGBE_DEV_ID_X550EM_X_SFP:
1162 media_type = ixgbe_media_type_fiber;
1164 case IXGBE_DEV_ID_X550EM_X_1G_T:
1165 case IXGBE_DEV_ID_X550EM_X_10G_T:
1166 media_type = ixgbe_media_type_copper;
1169 media_type = ixgbe_media_type_unknown;
1175 /** ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
1176 ** @hw: pointer to hardware structure
1178 static s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
1185 /* decrement retries counter and exit if we hit 0 */
1187 hw_dbg(hw, "External PHY not yet finished resetting.");
1188 return IXGBE_ERR_PHY;
1192 status = hw->phy.ops.read_reg(hw,
1193 IXGBE_MDIO_TX_VENDOR_ALARMS_3,
1194 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1199 /* Verify PHY FW reset has completed */
1200 } while ((reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) != 1);
1202 /* Set port to low power mode */
1203 status = hw->phy.ops.read_reg(hw,
1204 IXGBE_MDIO_VENDOR_SPECIFIC_1_CONTROL,
1205 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1210 /* Enable the transmitter */
1211 status = hw->phy.ops.read_reg(hw,
1212 IXGBE_MDIO_PMD_STD_TX_DISABLE_CNTR,
1213 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1218 reg &= ~IXGBE_MDIO_PMD_GLOBAL_TX_DISABLE;
1220 status = hw->phy.ops.write_reg(hw,
1221 IXGBE_MDIO_PMD_STD_TX_DISABLE_CNTR,
1222 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
1227 /* Un-stall the PHY FW */
1228 status = hw->phy.ops.read_reg(hw,
1229 IXGBE_MDIO_GLOBAL_RES_PR_10,
1230 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1235 reg &= ~IXGBE_MDIO_POWER_UP_STALL;
1237 status = hw->phy.ops.write_reg(hw,
1238 IXGBE_MDIO_GLOBAL_RES_PR_10,
1239 IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
1244 /** ixgbe_reset_hw_X550em - Perform hardware reset
1245 ** @hw: pointer to hardware structure
1247 ** Resets the hardware by resetting the transmit and receive units, masks
1248 ** and clears all interrupts, perform a PHY reset, and perform a link (MAC)
1251 static s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
1253 ixgbe_link_speed link_speed;
1257 bool link_up = false;
1259 /* Call adapter stop to disable Tx/Rx and clear interrupts */
1260 status = hw->mac.ops.stop_adapter(hw);
1264 /* flush pending Tx transactions */
1265 ixgbe_clear_tx_pending(hw);
1267 /* PHY ops must be identified and initialized prior to reset */
1269 /* Identify PHY and related function pointers */
1270 status = hw->phy.ops.init(hw);
1272 /* start the external PHY */
1273 if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
1274 status = ixgbe_init_ext_t_x550em(hw);
1279 /* Setup SFP module if there is one present. */
1280 if (hw->phy.sfp_setup_needed) {
1281 status = hw->mac.ops.setup_sfp(hw);
1282 hw->phy.sfp_setup_needed = false;
1286 if (!hw->phy.reset_disable && hw->phy.ops.reset)
1287 hw->phy.ops.reset(hw);
1290 /* Issue global reset to the MAC. Needs to be SW reset if link is up.
1291 * If link reset is used when link is up, it might reset the PHY when
1292 * mng is using it. If link is down or the flag to force full link
1293 * reset is set, then perform link reset.
1295 ctrl = IXGBE_CTRL_LNK_RST;
1297 if (!hw->force_full_reset) {
1298 hw->mac.ops.check_link(hw, &link_speed, &link_up, false);
1300 ctrl = IXGBE_CTRL_RST;
1303 ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
1304 IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
1305 IXGBE_WRITE_FLUSH(hw);
1307 /* Poll for reset bit to self-clear meaning reset is complete */
1308 for (i = 0; i < 10; i++) {
1310 ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
1311 if (!(ctrl & IXGBE_CTRL_RST_MASK))
1315 if (ctrl & IXGBE_CTRL_RST_MASK) {
1316 status = IXGBE_ERR_RESET_FAILED;
1317 hw_dbg(hw, "Reset polling failed to complete.\n");
1322 /* Double resets are required for recovery from certain error
1323 * clear the multicast table. Also reset num_rar_entries to 128,
1324 * since we modify this value when programming the SAN MAC address.
1326 if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
1327 hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
1331 /* Store the permanent mac address */
1332 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
1334 /* Store MAC address from RAR0, clear receive address registers, and
1335 * clear the multicast table. Also reset num_rar_entries to 128,
1336 * since we modify this value when programming the SAN MAC address.
1338 hw->mac.num_rar_entries = 128;
1339 hw->mac.ops.init_rx_addrs(hw);
1344 /** ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype
1346 * @hw: pointer to hardware structure
1347 * @enable: enable or disable switch for Ethertype anti-spoofing
1348 * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
1350 static void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
1351 bool enable, int vf)
1353 int vf_target_reg = vf >> 3;
1354 int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
1357 pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
1359 pfvfspoof |= (1 << vf_target_shift);
1361 pfvfspoof &= ~(1 << vf_target_shift);
1363 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
1366 /** ixgbe_set_source_address_pruning_X550 - Enable/Disbale src address pruning
1367 * @hw: pointer to hardware structure
1368 * @enable: enable or disable source address pruning
1369 * @pool: Rx pool to set source address pruning for
1371 static void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw,
1377 /* max rx pool is 63 */
1381 pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
1382 pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
1385 pfflp |= (1ULL << pool);
1387 pfflp &= ~(1ULL << pool);
1389 IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
1390 IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
1393 #define X550_COMMON_MAC \
1394 .init_hw = &ixgbe_init_hw_generic, \
1395 .start_hw = &ixgbe_start_hw_X540, \
1396 .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic, \
1397 .enable_rx_dma = &ixgbe_enable_rx_dma_generic, \
1398 .get_mac_addr = &ixgbe_get_mac_addr_generic, \
1399 .get_device_caps = &ixgbe_get_device_caps_generic, \
1400 .stop_adapter = &ixgbe_stop_adapter_generic, \
1401 .get_bus_info = &ixgbe_get_bus_info_generic, \
1402 .set_lan_id = &ixgbe_set_lan_id_multi_port_pcie, \
1403 .read_analog_reg8 = NULL, \
1404 .write_analog_reg8 = NULL, \
1405 .set_rxpba = &ixgbe_set_rxpba_generic, \
1406 .check_link = &ixgbe_check_mac_link_generic, \
1407 .led_on = &ixgbe_led_on_generic, \
1408 .led_off = &ixgbe_led_off_generic, \
1409 .blink_led_start = &ixgbe_blink_led_start_X540, \
1410 .blink_led_stop = &ixgbe_blink_led_stop_X540, \
1411 .set_rar = &ixgbe_set_rar_generic, \
1412 .clear_rar = &ixgbe_clear_rar_generic, \
1413 .set_vmdq = &ixgbe_set_vmdq_generic, \
1414 .set_vmdq_san_mac = &ixgbe_set_vmdq_san_mac_generic, \
1415 .clear_vmdq = &ixgbe_clear_vmdq_generic, \
1416 .init_rx_addrs = &ixgbe_init_rx_addrs_generic, \
1417 .update_mc_addr_list = &ixgbe_update_mc_addr_list_generic, \
1418 .enable_mc = &ixgbe_enable_mc_generic, \
1419 .disable_mc = &ixgbe_disable_mc_generic, \
1420 .clear_vfta = &ixgbe_clear_vfta_generic, \
1421 .set_vfta = &ixgbe_set_vfta_generic, \
1422 .fc_enable = &ixgbe_fc_enable_generic, \
1423 .set_fw_drv_ver = &ixgbe_set_fw_drv_ver_generic, \
1424 .init_uta_tables = &ixgbe_init_uta_tables_generic, \
1425 .set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing, \
1426 .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing, \
1427 .set_source_address_pruning = \
1428 &ixgbe_set_source_address_pruning_X550, \
1429 .set_ethertype_anti_spoofing = \
1430 &ixgbe_set_ethertype_anti_spoofing_X550, \
1431 .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X540, \
1432 .release_swfw_sync = &ixgbe_release_swfw_sync_X540, \
1433 .disable_rx_buff = &ixgbe_disable_rx_buff_generic, \
1434 .enable_rx_buff = &ixgbe_enable_rx_buff_generic, \
1435 .get_thermal_sensor_data = NULL, \
1436 .init_thermal_sensor_thresh = NULL, \
1437 .prot_autoc_read = &prot_autoc_read_generic, \
1438 .prot_autoc_write = &prot_autoc_write_generic, \
1439 .enable_rx = &ixgbe_enable_rx_generic, \
1440 .disable_rx = &ixgbe_disable_rx_x550, \
1442 static struct ixgbe_mac_operations mac_ops_X550 = {
1444 .reset_hw = &ixgbe_reset_hw_X540,
1445 .get_media_type = &ixgbe_get_media_type_X540,
1446 .get_san_mac_addr = &ixgbe_get_san_mac_addr_generic,
1447 .get_wwn_prefix = &ixgbe_get_wwn_prefix_generic,
1448 .setup_link = &ixgbe_setup_mac_link_X540,
1449 .get_link_capabilities = &ixgbe_get_copper_link_capabilities_generic,
1453 static struct ixgbe_mac_operations mac_ops_X550EM_x = {
1455 .reset_hw = &ixgbe_reset_hw_X550em,
1456 .get_media_type = &ixgbe_get_media_type_X550em,
1457 .get_san_mac_addr = NULL,
1458 .get_wwn_prefix = NULL,
1459 .setup_link = NULL, /* defined later */
1460 .get_link_capabilities = &ixgbe_get_link_capabilities_X550em,
1461 .setup_sfp = ixgbe_setup_sfp_modules_X550em,
1465 #define X550_COMMON_EEP \
1466 .read = &ixgbe_read_ee_hostif_X550, \
1467 .read_buffer = &ixgbe_read_ee_hostif_buffer_X550, \
1468 .write = &ixgbe_write_ee_hostif_X550, \
1469 .write_buffer = &ixgbe_write_ee_hostif_buffer_X550, \
1470 .validate_checksum = &ixgbe_validate_eeprom_checksum_X550, \
1471 .update_checksum = &ixgbe_update_eeprom_checksum_X550, \
1472 .calc_checksum = &ixgbe_calc_eeprom_checksum_X550, \
1474 static struct ixgbe_eeprom_operations eeprom_ops_X550 = {
1476 .init_params = &ixgbe_init_eeprom_params_X550,
1479 static struct ixgbe_eeprom_operations eeprom_ops_X550EM_x = {
1481 .init_params = &ixgbe_init_eeprom_params_X540,
1484 #define X550_COMMON_PHY \
1485 .identify_sfp = &ixgbe_identify_module_generic, \
1487 .setup_link_speed = &ixgbe_setup_phy_link_speed_generic, \
1488 .read_i2c_byte = &ixgbe_read_i2c_byte_generic, \
1489 .write_i2c_byte = &ixgbe_write_i2c_byte_generic, \
1490 .read_i2c_sff8472 = &ixgbe_read_i2c_sff8472_generic, \
1491 .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic, \
1492 .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic, \
1493 .check_overtemp = &ixgbe_tn_check_overtemp, \
1494 .get_firmware_version = &ixgbe_get_phy_firmware_version_generic,
1496 static struct ixgbe_phy_operations phy_ops_X550 = {
1499 .identify = &ixgbe_identify_phy_generic,
1500 .read_reg = &ixgbe_read_phy_reg_generic,
1501 .write_reg = &ixgbe_write_phy_reg_generic,
1502 .setup_link = &ixgbe_setup_phy_link_generic,
1503 .read_i2c_combined = &ixgbe_read_i2c_combined_generic,
1504 .write_i2c_combined = &ixgbe_write_i2c_combined_generic,
1507 static struct ixgbe_phy_operations phy_ops_X550EM_x = {
1509 .init = &ixgbe_init_phy_ops_X550em,
1510 .identify = &ixgbe_identify_phy_x550em,
1511 .read_reg = NULL, /* defined later */
1512 .write_reg = NULL, /* defined later */
1513 .setup_link = NULL, /* defined later */
1516 struct ixgbe_info ixgbe_X550_info = {
1517 .mac = ixgbe_mac_X550,
1518 .get_invariants = &ixgbe_get_invariants_X540,
1519 .mac_ops = &mac_ops_X550,
1520 .eeprom_ops = &eeprom_ops_X550,
1521 .phy_ops = &phy_ops_X550,
1522 .mbx_ops = &mbx_ops_generic,
1525 struct ixgbe_info ixgbe_X550EM_x_info = {
1526 .mac = ixgbe_mac_X550EM_x,
1527 .get_invariants = &ixgbe_get_invariants_X540,
1528 .mac_ops = &mac_ops_X550EM_x,
1529 .eeprom_ops = &eeprom_ops_X550EM_x,
1530 .phy_ops = &phy_ops_X550EM_x,
1531 .mbx_ops = &mbx_ops_generic,