Lines Matching +full:hw +full:- +full:flow +full:- +full:ctrl
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2018 Intel Corporation. */
9 * e1000e_get_bus_info_pcie - Get PCIe bus information
10 * @hw: pointer to the HW structure
16 s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw) in e1000e_get_bus_info_pcie() argument
18 struct pci_dev *pdev = hw->adapter->pdev; in e1000e_get_bus_info_pcie()
19 struct e1000_mac_info *mac = &hw->mac; in e1000e_get_bus_info_pcie()
20 struct e1000_bus_info *bus = &hw->bus; in e1000e_get_bus_info_pcie()
24 bus->width = e1000_bus_width_unknown; in e1000e_get_bus_info_pcie()
27 bus->width = (enum e1000_bus_width)FIELD_GET(PCI_EXP_LNKSTA_NLW, in e1000e_get_bus_info_pcie()
31 mac->ops.set_lan_id(hw); in e1000e_get_bus_info_pcie()
37 * e1000_set_lan_id_multi_port_pcie - Set LAN id for PCIe multiple port devices
39 * @hw: pointer to the HW structure
41 * Determines the LAN function id by reading memory-mapped registers
44 void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw) in e1000_set_lan_id_multi_port_pcie() argument
46 struct e1000_bus_info *bus = &hw->bus; in e1000_set_lan_id_multi_port_pcie()
53 bus->func = FIELD_GET(E1000_STATUS_FUNC_MASK, reg); in e1000_set_lan_id_multi_port_pcie()
57 * e1000_set_lan_id_single_port - Set LAN id for a single port device
58 * @hw: pointer to the HW structure
62 void e1000_set_lan_id_single_port(struct e1000_hw *hw) in e1000_set_lan_id_single_port() argument
64 struct e1000_bus_info *bus = &hw->bus; in e1000_set_lan_id_single_port()
66 bus->func = 0; in e1000_set_lan_id_single_port()
70 * e1000_clear_vfta_generic - Clear VLAN filter table
71 * @hw: pointer to the HW structure
76 void e1000_clear_vfta_generic(struct e1000_hw *hw) in e1000_clear_vfta_generic() argument
81 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, 0); in e1000_clear_vfta_generic()
87 * e1000_write_vfta_generic - Write value to VLAN filter table
88 * @hw: pointer to the HW structure
95 void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value) in e1000_write_vfta_generic() argument
97 E1000_WRITE_REG_ARRAY(hw, E1000_VFTA, offset, value); in e1000_write_vfta_generic()
102 * e1000e_init_rx_addrs - Initialize receive address's
103 * @hw: pointer to the HW structure
110 void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count) in e1000e_init_rx_addrs() argument
118 hw->mac.ops.rar_set(hw, hw->mac.addr, 0); in e1000e_init_rx_addrs()
120 /* Zero out the other (rar_entry_count - 1) receive addresses */ in e1000e_init_rx_addrs()
121 e_dbg("Clearing RAR[1-%u]\n", rar_count - 1); in e1000e_init_rx_addrs()
123 hw->mac.ops.rar_set(hw, mac_addr, i); in e1000e_init_rx_addrs()
127 * e1000_check_alt_mac_addr_generic - Check for alternate MAC addr
128 * @hw: pointer to the HW structure
131 * can be setup by pre-boot software and must be treated like a permanent
138 s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw) in e1000_check_alt_mac_addr_generic() argument
145 ret_val = e1000_read_nvm(hw, NVM_COMPAT, 1, &nvm_data); in e1000_check_alt_mac_addr_generic()
150 if (hw->mac.type == e1000_82573) in e1000_check_alt_mac_addr_generic()
153 ret_val = e1000_read_nvm(hw, NVM_ALT_MAC_ADDR_PTR, 1, in e1000_check_alt_mac_addr_generic()
165 if (hw->bus.func == E1000_FUNC_1) in e1000_check_alt_mac_addr_generic()
169 ret_val = e1000_read_nvm(hw, offset, 1, &nvm_data); in e1000_check_alt_mac_addr_generic()
186 * same as the normal permanent MAC address stored by the HW into the in e1000_check_alt_mac_addr_generic()
189 hw->mac.ops.rar_set(hw, alt_mac_addr, 0); in e1000_check_alt_mac_addr_generic()
194 u32 e1000e_rar_get_count_generic(struct e1000_hw *hw) in e1000e_rar_get_count_generic() argument
196 return hw->mac.rar_entry_count; in e1000e_rar_get_count_generic()
200 * e1000e_rar_set_generic - Set receive address register
201 * @hw: pointer to the HW structure
208 int e1000e_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index) in e1000e_rar_set_generic() argument
212 /* HW expects these in little endian so we reverse the byte order in e1000e_rar_set_generic()
224 /* Some bridges will combine consecutive 32-bit writes into in e1000e_rar_set_generic()
237 * e1000_hash_mc_addr - Generate a multicast hash value
238 * @hw: pointer to the HW structure
244 static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr) in e1000_hash_mc_addr() argument
250 hash_mask = (hw->mac.mta_reg_count * 32) - 1; in e1000_hash_mc_addr()
252 /* For a mc_filter_type of 0, bit_shift is the number of left-shifts in e1000_hash_mc_addr()
262 * left-shifts where the MSB of mc_addr[5] would still fall within in e1000_hash_mc_addr()
265 * remaining number of bits. Thus 8 - bit_shift. The rest of the in e1000_hash_mc_addr()
268 * 8-bit shifting total. in e1000_hash_mc_addr()
271 * mta register count of 128 (thus a 4096-bit vector and 0xFFF mask), in e1000_hash_mc_addr()
283 switch (hw->mac.mc_filter_type) { in e1000_hash_mc_addr()
298 hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) | in e1000_hash_mc_addr()
305 * e1000e_update_mc_addr_list_generic - Update Multicast addresses
306 * @hw: pointer to the HW structure
313 void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, in e1000e_update_mc_addr_list_generic() argument
320 memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow)); in e1000e_update_mc_addr_list_generic()
324 hash_value = e1000_hash_mc_addr(hw, mc_addr_list); in e1000e_update_mc_addr_list_generic()
326 hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1); in e1000e_update_mc_addr_list_generic()
329 hw->mac.mta_shadow[hash_reg] |= BIT(hash_bit); in e1000e_update_mc_addr_list_generic()
334 for (i = hw->mac.mta_reg_count - 1; i >= 0; i--) { in e1000e_update_mc_addr_list_generic()
335 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, hw->mac.mta_shadow[i]); in e1000e_update_mc_addr_list_generic()
353 * e1000e_clear_hw_cntrs_base - Clear base hardware counters
354 * @hw: pointer to the HW structure
358 void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw) in e1000e_clear_hw_cntrs_base() argument
400 * e1000e_check_for_copper_link - Check for link (Copper)
401 * @hw: pointer to the HW structure
407 s32 e1000e_check_for_copper_link(struct e1000_hw *hw) in e1000e_check_for_copper_link() argument
409 struct e1000_mac_info *mac = &hw->mac; in e1000e_check_for_copper_link()
413 /* We only want to go out to the PHY registers to see if Auto-Neg in e1000e_check_for_copper_link()
418 if (!mac->get_link_status) in e1000e_check_for_copper_link()
420 mac->get_link_status = false; in e1000e_check_for_copper_link()
426 ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); in e1000e_check_for_copper_link()
431 * immediately after link-up in e1000e_check_for_copper_link()
433 e1000e_check_downshift(hw); in e1000e_check_for_copper_link()
438 if (!mac->autoneg) in e1000e_check_for_copper_link()
439 return -E1000_ERR_CONFIG; in e1000e_check_for_copper_link()
441 /* Auto-Neg is enabled. Auto Speed Detection takes care in e1000e_check_for_copper_link()
445 mac->ops.config_collision_dist(hw); in e1000e_check_for_copper_link()
447 /* Configure Flow Control now that Auto-Neg has completed. in e1000e_check_for_copper_link()
448 * First, we need to restore the desired flow control in e1000e_check_for_copper_link()
449 * settings because we may have had to re-autoneg with a in e1000e_check_for_copper_link()
452 ret_val = e1000e_config_fc_after_link_up(hw); in e1000e_check_for_copper_link()
454 e_dbg("Error configuring flow control\n"); in e1000e_check_for_copper_link()
459 mac->get_link_status = true; in e1000e_check_for_copper_link()
464 * e1000e_check_for_fiber_link - Check for link (Fiber)
465 * @hw: pointer to the HW structure
470 s32 e1000e_check_for_fiber_link(struct e1000_hw *hw) in e1000e_check_for_fiber_link() argument
472 struct e1000_mac_info *mac = &hw->mac; in e1000e_check_for_fiber_link()
474 u32 ctrl; in e1000e_check_for_fiber_link() local
478 ctrl = er32(CTRL); in e1000e_check_for_fiber_link()
482 /* If we don't have link (auto-negotiation failed or link partner in e1000e_check_for_fiber_link()
483 * cannot auto-negotiate), the cable is plugged in (we have signal), in e1000e_check_for_fiber_link()
484 * and our link partner is not trying to auto-negotiate with us (we in e1000e_check_for_fiber_link()
486 * need to give auto-negotiation time to complete, in case the cable in e1000e_check_for_fiber_link()
489 /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */ in e1000e_check_for_fiber_link()
490 if ((ctrl & E1000_CTRL_SWDPIN1) && !(status & E1000_STATUS_LU) && in e1000e_check_for_fiber_link()
492 if (!mac->autoneg_failed) { in e1000e_check_for_fiber_link()
493 mac->autoneg_failed = true; in e1000e_check_for_fiber_link()
498 /* Disable auto-negotiation in the TXCW register */ in e1000e_check_for_fiber_link()
499 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE)); in e1000e_check_for_fiber_link()
501 /* Force link-up and also force full-duplex. */ in e1000e_check_for_fiber_link()
502 ctrl = er32(CTRL); in e1000e_check_for_fiber_link()
503 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD); in e1000e_check_for_fiber_link()
504 ew32(CTRL, ctrl); in e1000e_check_for_fiber_link()
506 /* Configure Flow Control after forcing link up. */ in e1000e_check_for_fiber_link()
507 ret_val = e1000e_config_fc_after_link_up(hw); in e1000e_check_for_fiber_link()
509 e_dbg("Error configuring flow control\n"); in e1000e_check_for_fiber_link()
512 } else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) { in e1000e_check_for_fiber_link()
514 * sets, re-enable auto-negotiation in the TXCW register in e1000e_check_for_fiber_link()
516 * in an attempt to auto-negotiate with our link partner. in e1000e_check_for_fiber_link()
519 ew32(TXCW, mac->txcw); in e1000e_check_for_fiber_link()
520 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); in e1000e_check_for_fiber_link()
522 mac->serdes_has_link = true; in e1000e_check_for_fiber_link()
529 * e1000e_check_for_serdes_link - Check for link (Serdes)
530 * @hw: pointer to the HW structure
535 s32 e1000e_check_for_serdes_link(struct e1000_hw *hw) in e1000e_check_for_serdes_link() argument
537 struct e1000_mac_info *mac = &hw->mac; in e1000e_check_for_serdes_link()
539 u32 ctrl; in e1000e_check_for_serdes_link() local
543 ctrl = er32(CTRL); in e1000e_check_for_serdes_link()
547 /* If we don't have link (auto-negotiation failed or link partner in e1000e_check_for_serdes_link()
548 * cannot auto-negotiate), and our link partner is not trying to in e1000e_check_for_serdes_link()
549 * auto-negotiate with us (we are receiving idles or data), in e1000e_check_for_serdes_link()
550 * we need to force link up. We also need to give auto-negotiation in e1000e_check_for_serdes_link()
553 /* (ctrl & E1000_CTRL_SWDPIN1) == 1 == have signal */ in e1000e_check_for_serdes_link()
555 if (!mac->autoneg_failed) { in e1000e_check_for_serdes_link()
556 mac->autoneg_failed = true; in e1000e_check_for_serdes_link()
561 /* Disable auto-negotiation in the TXCW register */ in e1000e_check_for_serdes_link()
562 ew32(TXCW, (mac->txcw & ~E1000_TXCW_ANE)); in e1000e_check_for_serdes_link()
564 /* Force link-up and also force full-duplex. */ in e1000e_check_for_serdes_link()
565 ctrl = er32(CTRL); in e1000e_check_for_serdes_link()
566 ctrl |= (E1000_CTRL_SLU | E1000_CTRL_FD); in e1000e_check_for_serdes_link()
567 ew32(CTRL, ctrl); in e1000e_check_for_serdes_link()
569 /* Configure Flow Control after forcing link up. */ in e1000e_check_for_serdes_link()
570 ret_val = e1000e_config_fc_after_link_up(hw); in e1000e_check_for_serdes_link()
572 e_dbg("Error configuring flow control\n"); in e1000e_check_for_serdes_link()
575 } else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) { in e1000e_check_for_serdes_link()
577 * sets, re-enable auto-negotiation in the TXCW register in e1000e_check_for_serdes_link()
579 * in an attempt to auto-negotiate with our link partner. in e1000e_check_for_serdes_link()
582 ew32(TXCW, mac->txcw); in e1000e_check_for_serdes_link()
583 ew32(CTRL, (ctrl & ~E1000_CTRL_SLU)); in e1000e_check_for_serdes_link()
585 mac->serdes_has_link = true; in e1000e_check_for_serdes_link()
587 /* If we force link for non-auto-negotiation switch, check in e1000e_check_for_serdes_link()
596 mac->serdes_has_link = true; in e1000e_check_for_serdes_link()
597 e_dbg("SERDES: Link up - forced.\n"); in e1000e_check_for_serdes_link()
600 mac->serdes_has_link = false; in e1000e_check_for_serdes_link()
601 e_dbg("SERDES: Link down - force failed.\n"); in e1000e_check_for_serdes_link()
613 mac->serdes_has_link = true; in e1000e_check_for_serdes_link()
614 e_dbg("SERDES: Link up - autoneg completed successfully.\n"); in e1000e_check_for_serdes_link()
616 mac->serdes_has_link = false; in e1000e_check_for_serdes_link()
617 e_dbg("SERDES: Link down - invalid codewords detected in autoneg.\n"); in e1000e_check_for_serdes_link()
620 mac->serdes_has_link = false; in e1000e_check_for_serdes_link()
621 e_dbg("SERDES: Link down - no sync.\n"); in e1000e_check_for_serdes_link()
624 mac->serdes_has_link = false; in e1000e_check_for_serdes_link()
625 e_dbg("SERDES: Link down - autoneg failed\n"); in e1000e_check_for_serdes_link()
633 * e1000_set_default_fc_generic - Set flow control default values
634 * @hw: pointer to the HW structure
636 * Read the EEPROM for the default values for flow control and store the
639 static s32 e1000_set_default_fc_generic(struct e1000_hw *hw) in e1000_set_default_fc_generic() argument
645 * that determine the hardware's default PAUSE (flow control) mode, in e1000_set_default_fc_generic()
646 * a bit that determines whether the HW defaults to enabling or in e1000_set_default_fc_generic()
647 * disabling auto-negotiation, and the direction of the in e1000_set_default_fc_generic()
648 * SW defined pins. If there is no SW over-ride of the flow in e1000_set_default_fc_generic()
649 * control setting, then the variable hw->fc will in e1000_set_default_fc_generic()
652 ret_val = e1000_read_nvm(hw, NVM_INIT_CONTROL2_REG, 1, &nvm_data); in e1000_set_default_fc_generic()
660 hw->fc.requested_mode = e1000_fc_none; in e1000_set_default_fc_generic()
662 hw->fc.requested_mode = e1000_fc_tx_pause; in e1000_set_default_fc_generic()
664 hw->fc.requested_mode = e1000_fc_full; in e1000_set_default_fc_generic()
670 * e1000e_setup_link_generic - Setup flow control and link settings
671 * @hw: pointer to the HW structure
673 * Determines which flow control settings to use, then configures flow
674 * control. Calls the appropriate media-specific link configuration
679 s32 e1000e_setup_link_generic(struct e1000_hw *hw) in e1000e_setup_link_generic() argument
686 if (hw->phy.ops.check_reset_block && hw->phy.ops.check_reset_block(hw)) in e1000e_setup_link_generic()
689 /* If requested flow control is set to default, set flow control in e1000e_setup_link_generic()
690 * based on the EEPROM flow control settings. in e1000e_setup_link_generic()
692 if (hw->fc.requested_mode == e1000_fc_default) { in e1000e_setup_link_generic()
693 ret_val = e1000_set_default_fc_generic(hw); in e1000e_setup_link_generic()
698 /* Save off the requested flow control mode for use later. Depending in e1000e_setup_link_generic()
701 hw->fc.current_mode = hw->fc.requested_mode; in e1000e_setup_link_generic()
703 e_dbg("After fix-ups FlowControl is now = %x\n", hw->fc.current_mode); in e1000e_setup_link_generic()
706 ret_val = hw->mac.ops.setup_physical_interface(hw); in e1000e_setup_link_generic()
710 /* Initialize the flow control address, type, and PAUSE timer in e1000e_setup_link_generic()
711 * registers to their default values. This is done even if flow in e1000e_setup_link_generic()
715 e_dbg("Initializing the Flow Control address, type and timer regs\n"); in e1000e_setup_link_generic()
720 ew32(FCTTV, hw->fc.pause_time); in e1000e_setup_link_generic()
722 return e1000e_set_fc_watermarks(hw); in e1000e_setup_link_generic()
726 * e1000_commit_fc_settings_generic - Configure flow control
727 * @hw: pointer to the HW structure
729 * Write the flow control settings to the Transmit Config Word Register (TXCW)
730 * base on the flow control settings in e1000_mac_info.
732 static s32 e1000_commit_fc_settings_generic(struct e1000_hw *hw) in e1000_commit_fc_settings_generic() argument
734 struct e1000_mac_info *mac = &hw->mac; in e1000_commit_fc_settings_generic()
737 /* Check for a software override of the flow control settings, and in e1000_commit_fc_settings_generic()
738 * setup the device accordingly. If auto-negotiation is enabled, then in e1000_commit_fc_settings_generic()
740 * the Transmit Config Word Register (TXCW) and re-start auto- in e1000_commit_fc_settings_generic()
741 * negotiation. However, if auto-negotiation is disabled, then in e1000_commit_fc_settings_generic()
742 * software will have to manually configure the two flow control enable in e1000_commit_fc_settings_generic()
743 * bits in the CTRL register. in e1000_commit_fc_settings_generic()
746 * 0: Flow control is completely disabled in e1000_commit_fc_settings_generic()
747 * 1: Rx flow control is enabled (we can receive pause frames, in e1000_commit_fc_settings_generic()
749 * 2: Tx flow control is enabled (we can send pause frames but we in e1000_commit_fc_settings_generic()
751 * 3: Both Rx and Tx flow control (symmetric) are enabled. in e1000_commit_fc_settings_generic()
753 switch (hw->fc.current_mode) { in e1000_commit_fc_settings_generic()
755 /* Flow control completely disabled by a software over-ride. */ in e1000_commit_fc_settings_generic()
759 /* Rx Flow control is enabled and Tx Flow control is disabled in e1000_commit_fc_settings_generic()
760 * by a software over-ride. Since there really isn't a way to in e1000_commit_fc_settings_generic()
769 /* Tx Flow control is enabled, and Rx Flow control is disabled, in e1000_commit_fc_settings_generic()
770 * by a software over-ride. in e1000_commit_fc_settings_generic()
775 /* Flow control (both Rx and Tx) is enabled by a software in e1000_commit_fc_settings_generic()
776 * over-ride. in e1000_commit_fc_settings_generic()
781 e_dbg("Flow control param set incorrectly\n"); in e1000_commit_fc_settings_generic()
782 return -E1000_ERR_CONFIG; in e1000_commit_fc_settings_generic()
786 mac->txcw = txcw; in e1000_commit_fc_settings_generic()
792 * e1000_poll_fiber_serdes_link_generic - Poll for link up
793 * @hw: pointer to the HW structure
796 * up with auto-negotiation, then the link is forced if a signal is detected.
798 static s32 e1000_poll_fiber_serdes_link_generic(struct e1000_hw *hw) in e1000_poll_fiber_serdes_link_generic() argument
800 struct e1000_mac_info *mac = &hw->mac; in e1000_poll_fiber_serdes_link_generic()
805 * serdes media) then poll for a "Link-Up" indication in the Device in e1000_poll_fiber_serdes_link_generic()
806 * Status Register. Time-out if a link isn't seen in 500 milliseconds in e1000_poll_fiber_serdes_link_generic()
807 * seconds (Auto-negotiation should complete in less than 500 in e1000_poll_fiber_serdes_link_generic()
817 e_dbg("Never got a valid link from auto-neg!!!\n"); in e1000_poll_fiber_serdes_link_generic()
818 mac->autoneg_failed = true; in e1000_poll_fiber_serdes_link_generic()
820 * mac->check_for_link. This routine will force the in e1000_poll_fiber_serdes_link_generic()
822 * communicate with non-autonegotiating link partners. in e1000_poll_fiber_serdes_link_generic()
824 ret_val = mac->ops.check_for_link(hw); in e1000_poll_fiber_serdes_link_generic()
829 mac->autoneg_failed = false; in e1000_poll_fiber_serdes_link_generic()
831 mac->autoneg_failed = false; in e1000_poll_fiber_serdes_link_generic()
839 * e1000e_setup_fiber_serdes_link - Setup link for fiber/serdes
840 * @hw: pointer to the HW structure
842 * Configures collision distance and flow control for fiber and serdes
845 s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw) in e1000e_setup_fiber_serdes_link() argument
847 u32 ctrl; in e1000e_setup_fiber_serdes_link() local
850 ctrl = er32(CTRL); in e1000e_setup_fiber_serdes_link()
853 ctrl &= ~E1000_CTRL_LRST; in e1000e_setup_fiber_serdes_link()
855 hw->mac.ops.config_collision_dist(hw); in e1000e_setup_fiber_serdes_link()
857 ret_val = e1000_commit_fc_settings_generic(hw); in e1000e_setup_fiber_serdes_link()
861 /* Since auto-negotiation is enabled, take the link out of reset (the in e1000e_setup_fiber_serdes_link()
863 * will restart auto-negotiation. If auto-negotiation is successful in e1000e_setup_fiber_serdes_link()
864 * then the link-up status bit will be set and the flow control enable in e1000e_setup_fiber_serdes_link()
867 e_dbg("Auto-negotiation enabled\n"); in e1000e_setup_fiber_serdes_link()
869 ew32(CTRL, ctrl); in e1000e_setup_fiber_serdes_link()
874 * detect a signal. If we have a signal, then poll for a "Link-Up" in e1000e_setup_fiber_serdes_link()
877 if (hw->phy.media_type == e1000_media_type_internal_serdes || in e1000e_setup_fiber_serdes_link()
878 (er32(CTRL) & E1000_CTRL_SWDPIN1)) { in e1000e_setup_fiber_serdes_link()
879 ret_val = e1000_poll_fiber_serdes_link_generic(hw); in e1000e_setup_fiber_serdes_link()
888 * e1000e_config_collision_dist_generic - Configure collision distance
889 * @hw: pointer to the HW structure
894 void e1000e_config_collision_dist_generic(struct e1000_hw *hw) in e1000e_config_collision_dist_generic() argument
908 * e1000e_set_fc_watermarks - Set flow control high/low watermarks
909 * @hw: pointer to the HW structure
911 * Sets the flow control high/low threshold (watermark) registers. If
912 * flow control XON frame transmission is enabled, then set XON frame
915 s32 e1000e_set_fc_watermarks(struct e1000_hw *hw) in e1000e_set_fc_watermarks() argument
919 /* Set the flow control receive threshold registers. Normally, in e1000e_set_fc_watermarks()
925 if (hw->fc.current_mode & e1000_fc_tx_pause) { in e1000e_set_fc_watermarks()
930 fcrtl = hw->fc.low_water; in e1000e_set_fc_watermarks()
931 if (hw->fc.send_xon) in e1000e_set_fc_watermarks()
934 fcrth = hw->fc.high_water; in e1000e_set_fc_watermarks()
943 * e1000e_force_mac_fc - Force the MAC's flow control settings
944 * @hw: pointer to the HW structure
946 * Force the MAC's flow control settings. Sets the TFCE and RFCE bits in the
952 s32 e1000e_force_mac_fc(struct e1000_hw *hw) in e1000e_force_mac_fc() argument
954 u32 ctrl; in e1000e_force_mac_fc() local
956 ctrl = er32(CTRL); in e1000e_force_mac_fc()
958 /* Because we didn't get link via the internal auto-negotiation in e1000e_force_mac_fc()
960 * auto-neg), we have to manually enable/disable transmit an in e1000e_force_mac_fc()
961 * receive flow control. in e1000e_force_mac_fc()
963 * The "Case" statement below enables/disable flow control in e1000e_force_mac_fc()
964 * according to the "hw->fc.current_mode" parameter. in e1000e_force_mac_fc()
967 * 0: Flow control is completely disabled in e1000e_force_mac_fc()
968 * 1: Rx flow control is enabled (we can receive pause in e1000e_force_mac_fc()
970 * 2: Tx flow control is enabled (we can send pause frames in e1000e_force_mac_fc()
972 * 3: Both Rx and Tx flow control (symmetric) is enabled. in e1000e_force_mac_fc()
975 e_dbg("hw->fc.current_mode = %u\n", hw->fc.current_mode); in e1000e_force_mac_fc()
977 switch (hw->fc.current_mode) { in e1000e_force_mac_fc()
979 ctrl &= (~(E1000_CTRL_TFCE | E1000_CTRL_RFCE)); in e1000e_force_mac_fc()
982 ctrl &= (~E1000_CTRL_TFCE); in e1000e_force_mac_fc()
983 ctrl |= E1000_CTRL_RFCE; in e1000e_force_mac_fc()
986 ctrl &= (~E1000_CTRL_RFCE); in e1000e_force_mac_fc()
987 ctrl |= E1000_CTRL_TFCE; in e1000e_force_mac_fc()
990 ctrl |= (E1000_CTRL_TFCE | E1000_CTRL_RFCE); in e1000e_force_mac_fc()
993 e_dbg("Flow control param set incorrectly\n"); in e1000e_force_mac_fc()
994 return -E1000_ERR_CONFIG; in e1000e_force_mac_fc()
997 ew32(CTRL, ctrl); in e1000e_force_mac_fc()
1003 * e1000e_config_fc_after_link_up - Configures flow control after link
1004 * @hw: pointer to the HW structure
1006 * Checks the status of auto-negotiation after link up to ensure that the
1008 * flow control needs to be forced also. If auto-negotiation is enabled
1009 * and did not fail, then we configure flow control based on our link
1012 s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw) in e1000e_config_fc_after_link_up() argument
1014 struct e1000_mac_info *mac = &hw->mac; in e1000e_config_fc_after_link_up()
1020 /* Check for the case where we have fiber media and auto-neg failed in e1000e_config_fc_after_link_up()
1024 if (mac->autoneg_failed) { in e1000e_config_fc_after_link_up()
1025 if (hw->phy.media_type == e1000_media_type_fiber || in e1000e_config_fc_after_link_up()
1026 hw->phy.media_type == e1000_media_type_internal_serdes) in e1000e_config_fc_after_link_up()
1027 ret_val = e1000e_force_mac_fc(hw); in e1000e_config_fc_after_link_up()
1029 if (hw->phy.media_type == e1000_media_type_copper) in e1000e_config_fc_after_link_up()
1030 ret_val = e1000e_force_mac_fc(hw); in e1000e_config_fc_after_link_up()
1034 e_dbg("Error forcing flow control settings\n"); in e1000e_config_fc_after_link_up()
1038 /* Check for the case where we have copper media and auto-neg is in e1000e_config_fc_after_link_up()
1039 * enabled. In this case, we need to check and see if Auto-Neg in e1000e_config_fc_after_link_up()
1041 * flow control configured. in e1000e_config_fc_after_link_up()
1043 if ((hw->phy.media_type == e1000_media_type_copper) && mac->autoneg) { in e1000e_config_fc_after_link_up()
1048 ret_val = e1e_rphy(hw, MII_BMSR, &mii_status_reg); in e1000e_config_fc_after_link_up()
1051 ret_val = e1e_rphy(hw, MII_BMSR, &mii_status_reg); in e1000e_config_fc_after_link_up()
1064 * flow control was negotiated. in e1000e_config_fc_after_link_up()
1066 ret_val = e1e_rphy(hw, MII_ADVERTISE, &mii_nway_adv_reg); in e1000e_config_fc_after_link_up()
1069 ret_val = e1e_rphy(hw, MII_LPA, &mii_nway_lp_ability_reg); in e1000e_config_fc_after_link_up()
1075 * Page Ability Register (Address 5) determine flow control in e1000e_config_fc_after_link_up()
1078 * 1999, describes these PAUSE resolution bits and how flow in e1000e_config_fc_after_link_up()
1084 *-------|---------|-------|---------|-------------------- in e1000e_config_fc_after_link_up()
1095 * Symmetric Flow Control is enabled at both ends. The in e1000e_config_fc_after_link_up()
1098 * For Symmetric Flow Control: in e1000e_config_fc_after_link_up()
1102 *-------|---------|-------|---------|-------------------- in e1000e_config_fc_after_link_up()
1110 * FULL flow control because we could not advertise Rx in e1000e_config_fc_after_link_up()
1114 if (hw->fc.requested_mode == e1000_fc_full) { in e1000e_config_fc_after_link_up()
1115 hw->fc.current_mode = e1000_fc_full; in e1000e_config_fc_after_link_up()
1116 e_dbg("Flow Control = FULL.\n"); in e1000e_config_fc_after_link_up()
1118 hw->fc.current_mode = e1000_fc_rx_pause; in e1000e_config_fc_after_link_up()
1119 e_dbg("Flow Control = Rx PAUSE frames only.\n"); in e1000e_config_fc_after_link_up()
1126 *-------|---------|-------|---------|-------------------- in e1000e_config_fc_after_link_up()
1133 hw->fc.current_mode = e1000_fc_tx_pause; in e1000e_config_fc_after_link_up()
1134 e_dbg("Flow Control = Tx PAUSE frames only.\n"); in e1000e_config_fc_after_link_up()
1140 *-------|---------|-------|---------|-------------------- in e1000e_config_fc_after_link_up()
1147 hw->fc.current_mode = e1000_fc_rx_pause; in e1000e_config_fc_after_link_up()
1148 e_dbg("Flow Control = Rx PAUSE frames only.\n"); in e1000e_config_fc_after_link_up()
1150 /* Per the IEEE spec, at this point flow control in e1000e_config_fc_after_link_up()
1153 hw->fc.current_mode = e1000_fc_none; in e1000e_config_fc_after_link_up()
1154 e_dbg("Flow Control = NONE.\n"); in e1000e_config_fc_after_link_up()
1157 /* Now we need to do one last check... If we auto- in e1000e_config_fc_after_link_up()
1158 * negotiated to HALF DUPLEX, flow control should not be in e1000e_config_fc_after_link_up()
1161 ret_val = mac->ops.get_link_up_info(hw, &speed, &duplex); in e1000e_config_fc_after_link_up()
1168 hw->fc.current_mode = e1000_fc_none; in e1000e_config_fc_after_link_up()
1171 * controller to use the correct flow control settings. in e1000e_config_fc_after_link_up()
1173 ret_val = e1000e_force_mac_fc(hw); in e1000e_config_fc_after_link_up()
1175 e_dbg("Error forcing flow control settings\n"); in e1000e_config_fc_after_link_up()
1180 /* Check for the case where we have SerDes media and auto-neg is in e1000e_config_fc_after_link_up()
1181 * enabled. In this case, we need to check and see if Auto-Neg in e1000e_config_fc_after_link_up()
1183 * flow control configured. in e1000e_config_fc_after_link_up()
1185 if ((hw->phy.media_type == e1000_media_type_internal_serdes) && in e1000e_config_fc_after_link_up()
1186 mac->autoneg) { in e1000e_config_fc_after_link_up()
1201 * flow control was negotiated. in e1000e_config_fc_after_link_up()
1208 * Page Ability Register (PCS_LPAB) determine flow control in e1000e_config_fc_after_link_up()
1211 * 1999, describes these PAUSE resolution bits and how flow in e1000e_config_fc_after_link_up()
1217 *-------|---------|-------|---------|-------------------- in e1000e_config_fc_after_link_up()
1228 * Symmetric Flow Control is enabled at both ends. The in e1000e_config_fc_after_link_up()
1231 * For Symmetric Flow Control: in e1000e_config_fc_after_link_up()
1235 *-------|---------|-------|---------|-------------------- in e1000e_config_fc_after_link_up()
1243 * FULL flow control because we could not advertise Rx in e1000e_config_fc_after_link_up()
1247 if (hw->fc.requested_mode == e1000_fc_full) { in e1000e_config_fc_after_link_up()
1248 hw->fc.current_mode = e1000_fc_full; in e1000e_config_fc_after_link_up()
1249 e_dbg("Flow Control = FULL.\n"); in e1000e_config_fc_after_link_up()
1251 hw->fc.current_mode = e1000_fc_rx_pause; in e1000e_config_fc_after_link_up()
1252 e_dbg("Flow Control = Rx PAUSE frames only.\n"); in e1000e_config_fc_after_link_up()
1259 *-------|---------|-------|---------|-------------------- in e1000e_config_fc_after_link_up()
1266 hw->fc.current_mode = e1000_fc_tx_pause; in e1000e_config_fc_after_link_up()
1267 e_dbg("Flow Control = Tx PAUSE frames only.\n"); in e1000e_config_fc_after_link_up()
1273 *-------|---------|-------|---------|-------------------- in e1000e_config_fc_after_link_up()
1280 hw->fc.current_mode = e1000_fc_rx_pause; in e1000e_config_fc_after_link_up()
1281 e_dbg("Flow Control = Rx PAUSE frames only.\n"); in e1000e_config_fc_after_link_up()
1283 /* Per the IEEE spec, at this point flow control in e1000e_config_fc_after_link_up()
1286 hw->fc.current_mode = e1000_fc_none; in e1000e_config_fc_after_link_up()
1287 e_dbg("Flow Control = NONE.\n"); in e1000e_config_fc_after_link_up()
1291 * controller to use the correct flow control settings. in e1000e_config_fc_after_link_up()
1297 ret_val = e1000e_force_mac_fc(hw); in e1000e_config_fc_after_link_up()
1299 e_dbg("Error forcing flow control settings\n"); in e1000e_config_fc_after_link_up()
1308 * e1000e_get_speed_and_duplex_copper - Retrieve current speed/duplex
1309 * @hw: pointer to the HW structure
1316 s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, in e1000e_get_speed_and_duplex_copper() argument
1342 * e1000e_get_speed_and_duplex_fiber_serdes - Retrieve current speed/duplex
1343 * @hw: pointer to the HW structure
1351 *hw, u16 *speed, u16 *duplex) in e1000e_get_speed_and_duplex_fiber_serdes()
1360 * e1000e_get_hw_semaphore - Acquire hardware semaphore
1361 * @hw: pointer to the HW structure
1363 * Acquire the HW semaphore to access the PHY or NVM
1365 s32 e1000e_get_hw_semaphore(struct e1000_hw *hw) in e1000e_get_hw_semaphore() argument
1368 s32 timeout = hw->nvm.word_size + 1; in e1000e_get_hw_semaphore()
1382 e_dbg("Driver can't access device - SMBI bit is set.\n"); in e1000e_get_hw_semaphore()
1383 return -E1000_ERR_NVM; in e1000e_get_hw_semaphore()
1400 e1000e_put_hw_semaphore(hw); in e1000e_get_hw_semaphore()
1402 return -E1000_ERR_NVM; in e1000e_get_hw_semaphore()
1409 * e1000e_put_hw_semaphore - Release hardware semaphore
1410 * @hw: pointer to the HW structure
1414 void e1000e_put_hw_semaphore(struct e1000_hw *hw) in e1000e_put_hw_semaphore() argument
1424 * e1000e_get_auto_rd_done - Check for auto read completion
1425 * @hw: pointer to the HW structure
1429 s32 e1000e_get_auto_rd_done(struct e1000_hw *hw) in e1000e_get_auto_rd_done() argument
1441 e_dbg("Auto read by HW from NVM has not completed.\n"); in e1000e_get_auto_rd_done()
1442 return -E1000_ERR_RESET; in e1000e_get_auto_rd_done()
1449 * e1000e_valid_led_default - Verify a valid default LED config
1450 * @hw: pointer to the HW structure
1456 s32 e1000e_valid_led_default(struct e1000_hw *hw, u16 *data) in e1000e_valid_led_default() argument
1460 ret_val = e1000_read_nvm(hw, NVM_ID_LED_SETTINGS, 1, data); in e1000e_valid_led_default()
1473 * e1000e_id_led_init_generic -
1474 * @hw: pointer to the HW structure
1477 s32 e1000e_id_led_init_generic(struct e1000_hw *hw) in e1000e_id_led_init_generic() argument
1479 struct e1000_mac_info *mac = &hw->mac; in e1000e_id_led_init_generic()
1487 ret_val = hw->nvm.ops.valid_led_default(hw, &data); in e1000e_id_led_init_generic()
1491 mac->ledctl_default = er32(LEDCTL); in e1000e_id_led_init_generic()
1492 mac->ledctl_mode1 = mac->ledctl_default; in e1000e_id_led_init_generic()
1493 mac->ledctl_mode2 = mac->ledctl_default; in e1000e_id_led_init_generic()
1501 mac->ledctl_mode1 &= ~(ledctl_mask << (i << 3)); in e1000e_id_led_init_generic()
1502 mac->ledctl_mode1 |= ledctl_on << (i << 3); in e1000e_id_led_init_generic()
1507 mac->ledctl_mode1 &= ~(ledctl_mask << (i << 3)); in e1000e_id_led_init_generic()
1508 mac->ledctl_mode1 |= ledctl_off << (i << 3); in e1000e_id_led_init_generic()
1518 mac->ledctl_mode2 &= ~(ledctl_mask << (i << 3)); in e1000e_id_led_init_generic()
1519 mac->ledctl_mode2 |= ledctl_on << (i << 3); in e1000e_id_led_init_generic()
1524 mac->ledctl_mode2 &= ~(ledctl_mask << (i << 3)); in e1000e_id_led_init_generic()
1525 mac->ledctl_mode2 |= ledctl_off << (i << 3); in e1000e_id_led_init_generic()
1537 * e1000e_setup_led_generic - Configures SW controllable LED
1538 * @hw: pointer to the HW structure
1543 s32 e1000e_setup_led_generic(struct e1000_hw *hw) in e1000e_setup_led_generic() argument
1547 if (hw->mac.ops.setup_led != e1000e_setup_led_generic) in e1000e_setup_led_generic()
1548 return -E1000_ERR_CONFIG; in e1000e_setup_led_generic()
1550 if (hw->phy.media_type == e1000_media_type_fiber) { in e1000e_setup_led_generic()
1552 hw->mac.ledctl_default = ledctl; in e1000e_setup_led_generic()
1559 } else if (hw->phy.media_type == e1000_media_type_copper) { in e1000e_setup_led_generic()
1560 ew32(LEDCTL, hw->mac.ledctl_mode1); in e1000e_setup_led_generic()
1567 * e1000e_cleanup_led_generic - Set LED config to default operation
1568 * @hw: pointer to the HW structure
1573 s32 e1000e_cleanup_led_generic(struct e1000_hw *hw) in e1000e_cleanup_led_generic() argument
1575 ew32(LEDCTL, hw->mac.ledctl_default); in e1000e_cleanup_led_generic()
1580 * e1000e_blink_led_generic - Blink LED
1581 * @hw: pointer to the HW structure
1585 s32 e1000e_blink_led_generic(struct e1000_hw *hw) in e1000e_blink_led_generic() argument
1590 if (hw->phy.media_type == e1000_media_type_fiber) { in e1000e_blink_led_generic()
1591 /* always blink LED0 for PCI-E fiber */ in e1000e_blink_led_generic()
1601 ledctl_blink = hw->mac.ledctl_mode2; in e1000e_blink_led_generic()
1603 u32 mode = (hw->mac.ledctl_mode2 >> i) & in e1000e_blink_led_generic()
1605 u32 led_default = hw->mac.ledctl_default >> i; in e1000e_blink_led_generic()
1625 * e1000e_led_on_generic - Turn LED on
1626 * @hw: pointer to the HW structure
1630 s32 e1000e_led_on_generic(struct e1000_hw *hw) in e1000e_led_on_generic() argument
1632 u32 ctrl; in e1000e_led_on_generic() local
1634 switch (hw->phy.media_type) { in e1000e_led_on_generic()
1636 ctrl = er32(CTRL); in e1000e_led_on_generic()
1637 ctrl &= ~E1000_CTRL_SWDPIN0; in e1000e_led_on_generic()
1638 ctrl |= E1000_CTRL_SWDPIO0; in e1000e_led_on_generic()
1639 ew32(CTRL, ctrl); in e1000e_led_on_generic()
1642 ew32(LEDCTL, hw->mac.ledctl_mode2); in e1000e_led_on_generic()
1652 * e1000e_led_off_generic - Turn LED off
1653 * @hw: pointer to the HW structure
1657 s32 e1000e_led_off_generic(struct e1000_hw *hw) in e1000e_led_off_generic() argument
1659 u32 ctrl; in e1000e_led_off_generic() local
1661 switch (hw->phy.media_type) { in e1000e_led_off_generic()
1663 ctrl = er32(CTRL); in e1000e_led_off_generic()
1664 ctrl |= E1000_CTRL_SWDPIN0; in e1000e_led_off_generic()
1665 ctrl |= E1000_CTRL_SWDPIO0; in e1000e_led_off_generic()
1666 ew32(CTRL, ctrl); in e1000e_led_off_generic()
1669 ew32(LEDCTL, hw->mac.ledctl_mode1); in e1000e_led_off_generic()
1679 * e1000e_set_pcie_no_snoop - Set PCI-express capabilities
1680 * @hw: pointer to the HW structure
1683 * Set the PCI-express register to snoop for events enabled in 'no_snoop'.
1685 void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop) in e1000e_set_pcie_no_snoop() argument
1698 * e1000e_disable_pcie_master - Disables PCI-express master access
1699 * @hw: pointer to the HW structure
1701 * Returns 0 if successful, else returns -10
1702 * (-E1000_ERR_MASTER_REQUESTS_PENDING) if master disable bit has not caused
1705 * Disables PCI-Express master access and verifies there are no pending
1708 s32 e1000e_disable_pcie_master(struct e1000_hw *hw) in e1000e_disable_pcie_master() argument
1710 u32 ctrl; in e1000e_disable_pcie_master() local
1713 ctrl = er32(CTRL); in e1000e_disable_pcie_master()
1714 ctrl |= E1000_CTRL_GIO_MASTER_DISABLE; in e1000e_disable_pcie_master()
1715 ew32(CTRL, ctrl); in e1000e_disable_pcie_master()
1721 timeout--; in e1000e_disable_pcie_master()
1726 return -E1000_ERR_MASTER_REQUESTS_PENDING; in e1000e_disable_pcie_master()
1733 * e1000e_reset_adaptive - Reset Adaptive Interframe Spacing
1734 * @hw: pointer to the HW structure
1738 void e1000e_reset_adaptive(struct e1000_hw *hw) in e1000e_reset_adaptive() argument
1740 struct e1000_mac_info *mac = &hw->mac; in e1000e_reset_adaptive()
1742 if (!mac->adaptive_ifs) { in e1000e_reset_adaptive()
1747 mac->current_ifs_val = 0; in e1000e_reset_adaptive()
1748 mac->ifs_min_val = IFS_MIN; in e1000e_reset_adaptive()
1749 mac->ifs_max_val = IFS_MAX; in e1000e_reset_adaptive()
1750 mac->ifs_step_size = IFS_STEP; in e1000e_reset_adaptive()
1751 mac->ifs_ratio = IFS_RATIO; in e1000e_reset_adaptive()
1753 mac->in_ifs_mode = false; in e1000e_reset_adaptive()
1758 * e1000e_update_adaptive - Update Adaptive Interframe Spacing
1759 * @hw: pointer to the HW structure
1764 void e1000e_update_adaptive(struct e1000_hw *hw) in e1000e_update_adaptive() argument
1766 struct e1000_mac_info *mac = &hw->mac; in e1000e_update_adaptive()
1768 if (!mac->adaptive_ifs) { in e1000e_update_adaptive()
1773 if ((mac->collision_delta * mac->ifs_ratio) > mac->tx_packet_delta) { in e1000e_update_adaptive()
1774 if (mac->tx_packet_delta > MIN_NUM_XMITS) { in e1000e_update_adaptive()
1775 mac->in_ifs_mode = true; in e1000e_update_adaptive()
1776 if (mac->current_ifs_val < mac->ifs_max_val) { in e1000e_update_adaptive()
1777 if (!mac->current_ifs_val) in e1000e_update_adaptive()
1778 mac->current_ifs_val = mac->ifs_min_val; in e1000e_update_adaptive()
1780 mac->current_ifs_val += in e1000e_update_adaptive()
1781 mac->ifs_step_size; in e1000e_update_adaptive()
1782 ew32(AIT, mac->current_ifs_val); in e1000e_update_adaptive()
1786 if (mac->in_ifs_mode && in e1000e_update_adaptive()
1787 (mac->tx_packet_delta <= MIN_NUM_XMITS)) { in e1000e_update_adaptive()
1788 mac->current_ifs_val = 0; in e1000e_update_adaptive()
1789 mac->in_ifs_mode = false; in e1000e_update_adaptive()