summaryrefslogtreecommitdiffstats
path: root/sys/dev/em/e1000_mac.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/em/e1000_mac.c')
-rw-r--r--sys/dev/em/e1000_mac.c152
1 files changed, 83 insertions, 69 deletions
diff --git a/sys/dev/em/e1000_mac.c b/sys/dev/em/e1000_mac.c
index 9f0f1b8..399a2c1 100644
--- a/sys/dev/em/e1000_mac.c
+++ b/sys/dev/em/e1000_mac.c
@@ -30,16 +30,15 @@
POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+/*$FreeBSD$*/
+#include "e1000_api.h"
#include "e1000_mac.h"
/**
* e1000_remove_device_generic - Free device specific structure
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* If a device specific structure was allocated, this function will
* free it.
@@ -55,7 +54,7 @@ e1000_remove_device_generic(struct e1000_hw *hw)
/**
* e1000_get_bus_info_pci_generic - Get PCI(x) bus information
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Determines and stores the system bus information for a particular
* network interface. The following bus information is determined and stored:
@@ -116,7 +115,7 @@ e1000_get_bus_info_pci_generic(struct e1000_hw *hw)
/**
* e1000_get_bus_info_pcie_generic - Get PCIe bus information
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Determines and stores the system bus information for a particular
* network interface. The following bus information is determined and stored:
@@ -158,7 +157,7 @@ e1000_get_bus_info_pcie_generic(struct e1000_hw *hw)
/**
* e1000_clear_vfta_generic - Clear VLAN filter table
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Clears the register array which contains the VLAN filter table by
* setting all the values to 0.
@@ -178,9 +177,9 @@ e1000_clear_vfta_generic(struct e1000_hw *hw)
/**
* e1000_write_vfta_generic - Write value to VLAN filter table
- * @hw - pointer to the HW structure
- * @offset - register offset in VLAN filter table
- * @value - register value written to VLAN filter table
+ * @hw: pointer to the HW structure
+ * @offset: register offset in VLAN filter table
+ * @value: register value written to VLAN filter table
*
* Writes value at the given offset in the register array which stores
* the VLAN filter table.
@@ -196,8 +195,8 @@ e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value)
/**
* e1000_init_rx_addrs_generic - Initialize receive address's
- * @hw - pointer to the HW structure
- * @rar_count - receive address registers
+ * @hw: pointer to the HW structure
+ * @rar_count: receive address registers
*
* Setups the receive address registers by setting the base receive address
* register to the devices MAC address and clearing all the other receive
@@ -227,9 +226,9 @@ e1000_init_rx_addrs_generic(struct e1000_hw *hw, u16 rar_count)
/**
* e1000_rar_set_generic - Set receive address register
- * @hw - pointer to the HW structure
- * @addr - pointer to the receive address
- * @index - receive address array register
+ * @hw: pointer to the HW structure
+ * @addr: pointer to the receive address
+ * @index: receive address array register
*
* Sets the receive address array register at index to the address passed
* in by addr.
@@ -259,8 +258,8 @@ e1000_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index)
/**
* e1000_mta_set_generic - Set multicast filter table address
- * @hw - pointer to the HW structure
- * @hash_value - determines the MTA register and bit to set
+ * @hw: pointer to the HW structure
+ * @hash_value: determines the MTA register and bit to set
*
* The multicast table address is a register array of 32-bit registers.
* The hash_value is used to determine what register the bit is in, the
@@ -295,11 +294,11 @@ e1000_mta_set_generic(struct e1000_hw *hw, u32 hash_value)
/**
* e1000_mc_addr_list_update_generic - Update Multicast addresses
- * @hw - pointer to the HW structure
- * @mc_addr_list - array of multicast addresses to program
- * @mc_addr_count - number of multicast addresses to program
- * @rar_used_count - the first RAR register free to program
- * @rar_count - total number of supported Receive Address Registers
+ * @hw: pointer to the HW structure
+ * @mc_addr_list: array of multicast addresses to program
+ * @mc_addr_count: number of multicast addresses to program
+ * @rar_used_count: the first RAR register free to program
+ * @rar_count: total number of supported Receive Address Registers
*
* Updates the Receive Address Registers and Multicast Table Array.
* The caller must have a packed mc_addr_list of multicast addresses.
@@ -351,8 +350,8 @@ e1000_mc_addr_list_update_generic(struct e1000_hw *hw,
/**
* e1000_hash_mc_addr_generic - Generate a multicast hash value
- * @hw - pointer to the HW structure
- * @mc_addr - pointer to a multicast address
+ * @hw: pointer to the HW structure
+ * @mc_addr: pointer to a multicast address
*
* Generates a multicast address hash value which is used to determine
* the multicast filter table array address and new table value. See
@@ -422,7 +421,7 @@ e1000_hash_mc_addr_generic(struct e1000_hw *hw, u8 *mc_addr)
/**
* e1000_pcix_mmrbc_workaround_generic - Fix incorrect MMRBC value
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* In certain situations, a system BIOS may report that the PCIx maximum
* memory read byte count (MMRBC) value is higher than than the actual
@@ -460,7 +459,7 @@ e1000_pcix_mmrbc_workaround_generic(struct e1000_hw *hw)
/**
* e1000_clear_hw_cntrs_base_generic - Clear base hardware counters
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Clears the base hardware counters by reading the counter registers.
**/
@@ -512,7 +511,7 @@ e1000_clear_hw_cntrs_base_generic(struct e1000_hw *hw)
/**
* e1000_check_for_copper_link_generic - Check for link (Copper)
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Checks to see of the link status of the hardware has changed. If a
* change in link status has been detected, then we read the PHY registers
@@ -584,7 +583,7 @@ out:
/**
* e1000_check_for_fiber_link_generic - Check for link (Fiber)
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Checks for link up on the hardware. If link is not up and we have
* a signal, then we need to force link up.
@@ -653,7 +652,7 @@ out:
/**
* e1000_check_for_serdes_link_generic - Check for link (Serdes)
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Checks for link up on the hardware. If link is not up and we have
* a signal, then we need to force link up.
@@ -743,7 +742,7 @@ out:
/**
* e1000_setup_link_generic - Setup flow control and link settings
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Determines which flow control settings to use, then configures flow
* control. Calls the appropriate media-specific link configuration
@@ -803,7 +802,7 @@ out:
/**
* e1000_setup_fiber_serdes_link_generic - Setup link for fiber/serdes
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Configures collision distance and flow control for fiber and serdes
* links. Upon successful setup, poll for link.
@@ -856,7 +855,7 @@ out:
/**
* e1000_config_collision_dist_generic - Configure collision distance
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Configures the collision distance to the default value and is used
* during link setup. Currently no func pointer exists and all
@@ -880,7 +879,7 @@ e1000_config_collision_dist_generic(struct e1000_hw *hw)
/**
* e1000_poll_fiber_serdes_link_generic - Poll for link up
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Polls for link up by reading the status register, if link fails to come
* up with auto-negotiation, then the link is forced if a signal is detected.
@@ -931,7 +930,7 @@ out:
/**
* e1000_commit_fc_settings_generic - Configure flow control
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Write the flow control settings to the Transmit Config Word Register (TXCW)
* base on the flow control settings in e1000_mac_info.
@@ -1004,7 +1003,7 @@ out:
/**
* e1000_set_fc_watermarks_generic - Set flow control high/low watermarks
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Sets the flow control high/low threshold (watermark) registers. If
* flow control XON frame transmission is enabled, then set XON frame
@@ -1044,7 +1043,7 @@ e1000_set_fc_watermarks_generic(struct e1000_hw *hw)
/**
* e1000_set_default_fc_generic - Set flow control default values
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Read the EEPROM for the default values for flow control and store the
* values.
@@ -1090,7 +1089,7 @@ out:
/**
* e1000_force_mac_fc_generic - Force the MAC's flow control settings
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Force the MAC's flow control settings. Sets the TFCE and RFCE bits in the
* device control register to reflect the adapter settings. TFCE and RFCE
@@ -1157,7 +1156,7 @@ out:
/**
* e1000_config_fc_after_link_up_generic - Configures flow control after link
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Checks the status of auto-negotiation after link up to ensure that the
* speed and duplex were not forced. If the link needed to be forced, then
@@ -1371,9 +1370,9 @@ out:
/**
* e1000_get_speed_and_duplex_copper_generic - Retreive current speed/duplex
- * @hw - pointer to the HW structure
- * @speed - stores the current speed
- * @duplex - stores the current duplex
+ * @hw: pointer to the HW structure
+ * @speed: stores the current speed
+ * @duplex: stores the current duplex
*
* Read the status register for the current speed/duplex and store the current
* speed and duplex for copper connections.
@@ -1411,9 +1410,9 @@ e1000_get_speed_and_duplex_copper_generic(struct e1000_hw *hw, u16 *speed,
/**
* e1000_get_speed_and_duplex_fiber_generic - Retreive current speed/duplex
- * @hw - pointer to the HW structure
- * @speed - stores the current speed
- * @duplex - stores the current duplex
+ * @hw: pointer to the HW structure
+ * @speed: stores the current speed
+ * @duplex: stores the current duplex
*
* Sets the speed and duplex to gigabit full duplex (the only possible option)
* for fiber/serdes links.
@@ -1432,10 +1431,9 @@ e1000_get_speed_and_duplex_fiber_serdes_generic(struct e1000_hw *hw, u16 *speed,
/**
* e1000_get_hw_semaphore_generic - Acquire hardware semaphore
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
- * Request a hardware semaphore by setting the firmware semaphore bit, once
- * bit has been set, semaphore has been acquired.
+ * Acquire the HW semaphore to access the PHY or NVM
**/
s32
e1000_get_hw_semaphore_generic(struct e1000_hw *hw)
@@ -1447,6 +1445,22 @@ e1000_get_hw_semaphore_generic(struct e1000_hw *hw)
DEBUGFUNC("e1000_get_hw_semaphore_generic");
+ /* Get the SW semaphore */
+ while (i < timeout) {
+ swsm = E1000_READ_REG(hw, E1000_SWSM);
+ if (!(swsm & E1000_SWSM_SMBI))
+ break;
+
+ usec_delay(50);
+ i++;
+ }
+
+ if (i == timeout) {
+ DEBUGOUT("Driver can't access device - SMBI bit is set.\n");
+ ret_val = -E1000_ERR_NVM;
+ goto out;
+ }
+
/* Get the FW semaphore. */
for (i = 0; i < timeout; i++) {
swsm = E1000_READ_REG(hw, E1000_SWSM);
@@ -1473,9 +1487,9 @@ out:
/**
* e1000_put_hw_semaphore_generic - Release hardware semaphore
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
- * Release hardware semaphore by clearing in the firmware semaphore bit.
+ * Release hardware semaphore used to access the PHY or NVM
**/
void
e1000_put_hw_semaphore_generic(struct e1000_hw *hw)
@@ -1486,14 +1500,14 @@ e1000_put_hw_semaphore_generic(struct e1000_hw *hw)
swsm = E1000_READ_REG(hw, E1000_SWSM);
- swsm &= ~E1000_SWSM_SWESMBI;
+ swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
E1000_WRITE_REG(hw, E1000_SWSM, swsm);
}
/**
* e1000_get_auto_rd_done_generic - Check for auto read completion
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Check EEPROM for Auto Read done bit.
**/
@@ -1524,8 +1538,8 @@ out:
/**
* e1000_valid_led_default_generic - Verify a valid default LED config
- * @hw - pointer to the HW structure
- * @data - pointer to the NVM (EEPROM)
+ * @hw: pointer to the HW structure
+ * @data: pointer to the NVM (EEPROM)
*
* Read the EEPROM for the current default LED configuration. If the
* LED configuration is not valid, set to a valid LED configuration.
@@ -1552,7 +1566,7 @@ out:
/**
* e1000_id_led_init_generic -
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
**/
s32
@@ -1620,7 +1634,7 @@ out:
/**
* e1000_setup_led_generic - Configures SW controllable LED
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* This prepares the SW controllable LED for use and saves the current state
* of the LED so it can be later restored.
@@ -1658,7 +1672,7 @@ out:
/**
* e1000_cleanup_led_generic - Set LED config to default operation
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Remove the current LED configuration and set the LED configuration
* to the default value, saved from the EEPROM.
@@ -1683,7 +1697,7 @@ out:
/**
* e1000_blink_led_generic - Blink LED
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Blink the led's which are set to be on.
**/
@@ -1717,7 +1731,7 @@ e1000_blink_led_generic(struct e1000_hw *hw)
/**
* e1000_led_on_generic - Turn LED on
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Turn LED on.
**/
@@ -1747,7 +1761,7 @@ e1000_led_on_generic(struct e1000_hw *hw)
/**
* e1000_led_off_generic - Turn LED off
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Turn LED off.
**/
@@ -1777,8 +1791,8 @@ e1000_led_off_generic(struct e1000_hw *hw)
/**
* e1000_set_pcie_no_snoop_generic - Set PCI-express capabilities
- * @hw - pointer to the HW structure
- * @no_snoop - bitmap of snoop events
+ * @hw: pointer to the HW structure
+ * @no_snoop: bitmap of snoop events
*
* Set the PCI-express register to snoop for events enabled in 'no_snoop'.
**/
@@ -1804,7 +1818,7 @@ out:
/**
* e1000_disable_pcie_master_generic - Disables PCI-express master access
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Returns 0 (E1000_SUCCESS) if successful, else returns -10
* (-E1000_ERR_MASTER_REQUESTS_PENDING) if master disable bit has not casued
@@ -1849,7 +1863,7 @@ out:
/**
* e1000_reset_adaptive_generic - Reset Adaptive Interframe Spacing
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Reset the Adaptive Interframe Spacing throttle to default values.
**/
@@ -1881,7 +1895,7 @@ out:
/**
* e1000_update_adaptive_generic - Update Adaptive Interframe Spacing
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Update the Adaptive Interframe Spacing Throttle value based on the
* time between transmitted packets and time between collisions.
@@ -1924,7 +1938,7 @@ out:
/**
* e1000_validate_mdi_setting_generic - Verify MDI/MDIx settings
- * @hw - pointer to the HW structure
+ * @hw: pointer to the HW structure
*
* Verify that when not using auto-negotitation that MDI/MDIx is correctly
* set, which is forced to MDI mode only.
@@ -1949,10 +1963,10 @@ out:
/**
* e1000_write_8bit_ctrl_reg_generic - Write a 8bit CTRL register
- * @hw - pointer to the HW structure
- * @reg - 32bit register offset such as E1000_SCTL
- * @offset - register offset to write to
- * @data - data to write at register offset
+ * @hw: pointer to the HW structure
+ * @reg: 32bit register offset such as E1000_SCTL
+ * @offset: register offset to write to
+ * @data: data to write at register offset
*
* Writes an address/data control type register. There are several of these
* and they all have the format address << 8 | data and bit 31 is polled for
OpenPOWER on IntegriCloud