28 #include <linux/pci.h>
30 #include <linux/sched.h>
35 #define IXGBE_X540_MAX_TX_QUEUES 128
36 #define IXGBE_X540_MAX_RX_QUEUES 128
37 #define IXGBE_X540_RAR_ENTRIES 128
38 #define IXGBE_X540_MC_TBL_SIZE 128
39 #define IXGBE_X540_VFT_TBL_SIZE 128
40 #define IXGBE_X540_RX_PB_SIZE 384
43 static s32 ixgbe_poll_flash_update_done_X540(
struct ixgbe_hw *
hw);
46 static s32 ixgbe_get_swfw_sync_semaphore(
struct ixgbe_hw *
hw);
47 static void ixgbe_release_swfw_sync_semaphore(
struct ixgbe_hw *
hw);
80 bool autoneg_wait_to_complete)
82 return hw->
phy.ops.setup_link_speed(hw, speed, autoneg,
83 autoneg_wait_to_complete);
100 status = hw->
mac.ops.stop_adapter(hw);
114 for (i = 0; i < 10; i++) {
123 hw_dbg(hw,
"Reset polling failed to complete.\n");
141 hw->
mac.ops.get_mac_addr(hw, hw->
mac.perm_addr);
149 hw->
mac.ops.init_rx_addrs(hw);
152 hw->
mac.ops.get_san_mac_addr(hw, hw->
mac.san_addr);
156 hw->
mac.ops.set_rar(hw, hw->
mac.num_rar_entries - 1,
160 hw->
mac.san_mac_rar_index = hw->
mac.num_rar_entries - 1;
163 hw->
mac.num_rar_entries--;
167 hw->
mac.ops.get_wwn_prefix(hw, &hw->
mac.wwnn_prefix,
168 &hw->
mac.wwpn_prefix);
182 static s32 ixgbe_start_hw_X540(
struct ixgbe_hw *hw)
202 static u32 ixgbe_get_supported_physical_layer_X540(
struct ixgbe_hw *hw)
207 hw->
phy.ops.identify(hw);
218 return physical_layer;
228 static s32 ixgbe_init_eeprom_params_X540(
struct ixgbe_hw *hw)
244 hw_dbg(hw,
"Eeprom params: type = %d, size = %d\n",
282 static s32 ixgbe_read_eerd_buffer_X540(
struct ixgbe_hw *hw,
328 static s32 ixgbe_write_eewr_buffer_X540(
struct ixgbe_hw *hw,
352 static u16 ixgbe_calc_eeprom_checksum_X540(
struct ixgbe_hw *hw)
370 hw_dbg(hw,
"EEPROM read failed\n");
385 hw_dbg(hw,
"EEPROM read failed\n");
390 if (pointer == 0xFFFF || pointer == 0 ||
391 pointer >= hw->
eeprom.word_size)
395 hw_dbg(hw,
"EEPROM read failed\n");
400 if (length == 0xFFFF || length == 0 ||
401 (pointer + length) >= hw->
eeprom.word_size)
404 for (j = pointer+1; j <= pointer+
length; j++) {
406 hw_dbg(hw,
"EEPROM read failed\n");
426 static s32 ixgbe_validate_eeprom_checksum_X540(
struct ixgbe_hw *hw,
431 u16 read_checksum = 0;
438 status = hw->
eeprom.ops.read(hw, 0, &checksum);
441 hw_dbg(hw,
"EEPROM read failed\n");
446 checksum = hw->
eeprom.ops.calc_checksum(hw);
459 if (read_checksum != checksum)
482 static s32 ixgbe_update_eeprom_checksum_X540(
struct ixgbe_hw *hw)
492 status = hw->
eeprom.ops.read(hw, 0, &checksum);
495 hw_dbg(hw,
"EEPROM read failed\n");
498 checksum = hw->
eeprom.ops.calc_checksum(hw);
508 status = ixgbe_update_flash_X540(hw);
525 static s32 ixgbe_update_flash_X540(
struct ixgbe_hw *hw)
530 status = ixgbe_poll_flash_update_done_X540(hw);
532 hw_dbg(hw,
"Flash update time out\n");
539 status = ixgbe_poll_flash_update_done_X540(hw);
541 hw_dbg(hw,
"Flash update complete\n");
543 hw_dbg(hw,
"Flash update time out\n");
553 status = ixgbe_poll_flash_update_done_X540(hw);
555 hw_dbg(hw,
"Flash update complete\n");
557 hw_dbg(hw,
"Flash update time out\n");
570 static s32 ixgbe_poll_flash_update_done_X540(
struct ixgbe_hw *hw)
599 u32 fwmask = mask << 5;
607 for (i = 0; i < timeout; i++) {
612 if (ixgbe_get_swfw_sync_semaphore(hw))
616 if (!(swfw_sync & (fwmask | swmask | hwmask))) {
619 ixgbe_release_swfw_sync_semaphore(hw);
628 ixgbe_release_swfw_sync_semaphore(hw);
641 if (swfw_sync & (fwmask | hwmask)) {
642 if (ixgbe_get_swfw_sync_semaphore(hw))
647 ixgbe_release_swfw_sync_semaphore(hw);
663 static void ixgbe_release_swfw_sync_X540(
struct ixgbe_hw *hw,
u16 mask)
668 ixgbe_get_swfw_sync_semaphore(hw);
671 swfw_sync &= ~swmask;
674 ixgbe_release_swfw_sync_semaphore(hw);
684 static s32 ixgbe_get_swfw_sync_semaphore(
struct ixgbe_hw *hw)
692 for (i = 0; i < timeout; i++) {
707 for (i = 0; i < timeout; i++) {
715 hw_dbg(hw,
"Software semaphore SMBI between device drivers "
728 static void ixgbe_release_swfw_sync_semaphore(
struct ixgbe_hw *hw)
765 hw->
mac.ops.check_link(hw, &speed, &link_up,
false);
789 static s32 ixgbe_blink_led_stop_X540(
struct ixgbe_hw *hw,
u32 index)
811 .reset_hw = &ixgbe_reset_hw_X540,
812 .start_hw = &ixgbe_start_hw_X540,
814 .get_media_type = &ixgbe_get_media_type_X540,
815 .get_supported_physical_layer =
816 &ixgbe_get_supported_physical_layer_X540,
825 .read_analog_reg8 =
NULL,
826 .write_analog_reg8 =
NULL,
827 .setup_link = &ixgbe_setup_mac_link_X540,
833 .blink_led_start = &ixgbe_blink_led_start_X540,
834 .blink_led_stop = &ixgbe_blink_led_stop_X540,
852 .acquire_swfw_sync = &ixgbe_acquire_swfw_sync_X540,
853 .release_swfw_sync = &ixgbe_release_swfw_sync_X540,
856 .get_thermal_sensor_data =
NULL,
857 .init_thermal_sensor_thresh =
NULL,
861 .init_params = &ixgbe_init_eeprom_params_X540,
862 .read = &ixgbe_read_eerd_X540,
863 .read_buffer = &ixgbe_read_eerd_buffer_X540,
864 .write = &ixgbe_write_eewr_X540,
865 .write_buffer = &ixgbe_write_eewr_buffer_X540,
866 .calc_checksum = &ixgbe_calc_eeprom_checksum_X540,
867 .validate_checksum = &ixgbe_validate_eeprom_checksum_X540,
868 .update_checksum = &ixgbe_update_eeprom_checksum_X540,
890 .get_invariants = &ixgbe_get_invariants_X540,
891 .mac_ops = &mac_ops_X540,
892 .eeprom_ops = &eeprom_ops_X540,
893 .phy_ops = &phy_ops_X540,