⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e1000_82543.c

📁 linux系统的网卡驱动包
💻 C
📖 第 1 页 / 共 4 页
字号:
/*******************************************************************************  Intel PRO/1000 Linux driver  Copyright(c) 1999 - 2008 Intel Corporation.  This program is free software; you can redistribute it and/or modify it  under the terms and conditions of the GNU General Public License,  version 2, as published by the Free Software Foundation.  This program is distributed in the hope it will be useful, but WITHOUT  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for  more details.  You should have received a copy of the GNU General Public License along with  this program; if not, write to the Free Software Foundation, Inc.,  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.  The full GNU General Public License is included in this distribution in  the file called "COPYING".  Contact Information:  Linux NICS <linux.nics@intel.com>  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497*******************************************************************************//* e1000_82543 * e1000_82544 */#include "e1000_api.h"#include "e1000_82543.h"static s32  e1000_init_phy_params_82543(struct e1000_hw *hw);static s32  e1000_init_nvm_params_82543(struct e1000_hw *hw);static s32  e1000_init_mac_params_82543(struct e1000_hw *hw);static s32  e1000_read_phy_reg_82543(struct e1000_hw *hw, u32 offset,                                     u16 *data);static s32  e1000_write_phy_reg_82543(struct e1000_hw *hw, u32 offset,                                      u16 data);static s32  e1000_phy_force_speed_duplex_82543(struct e1000_hw *hw);static s32  e1000_phy_hw_reset_82543(struct e1000_hw *hw);static s32  e1000_reset_hw_82543(struct e1000_hw *hw);static s32  e1000_init_hw_82543(struct e1000_hw *hw);static s32  e1000_setup_link_82543(struct e1000_hw *hw);static s32  e1000_setup_copper_link_82543(struct e1000_hw *hw);static s32  e1000_setup_fiber_link_82543(struct e1000_hw *hw);static s32  e1000_check_for_copper_link_82543(struct e1000_hw *hw);static s32  e1000_check_for_fiber_link_82543(struct e1000_hw *hw);static s32  e1000_led_on_82543(struct e1000_hw *hw);static s32  e1000_led_off_82543(struct e1000_hw *hw);static void e1000_write_vfta_82543(struct e1000_hw *hw, u32 offset,                                   u32 value);static void e1000_mta_set_82543(struct e1000_hw *hw, u32 hash_value);static void e1000_clear_hw_cntrs_82543(struct e1000_hw *hw);static s32  e1000_config_mac_to_phy_82543(struct e1000_hw *hw);static bool e1000_init_phy_disabled_82543(struct e1000_hw *hw);static void e1000_lower_mdi_clk_82543(struct e1000_hw *hw, u32 *ctrl);static s32  e1000_polarity_reversal_workaround_82543(struct e1000_hw *hw);static void e1000_raise_mdi_clk_82543(struct e1000_hw *hw, u32 *ctrl);static u16  e1000_shift_in_mdi_bits_82543(struct e1000_hw *hw);static void e1000_shift_out_mdi_bits_82543(struct e1000_hw *hw, u32 data,                                           u16 count);static bool e1000_tbi_compatibility_enabled_82543(struct e1000_hw *hw);static void e1000_set_tbi_sbp_82543(struct e1000_hw *hw, bool state);struct e1000_dev_spec_82543 {	u32  tbi_compatibility;	bool dma_fairness;	bool init_phy_disabled;};/** *  e1000_init_phy_params_82543 - Init PHY func ptrs. *  @hw: pointer to the HW structure * *  This is a function pointer entry point called by the api module. **/static s32 e1000_init_phy_params_82543(struct e1000_hw *hw){	struct e1000_phy_info *phy = &hw->phy;	struct e1000_functions *func = &hw->func;	s32 ret_val = E1000_SUCCESS;	DEBUGFUNC("e1000_init_phy_params_82543");	if (hw->phy.media_type != e1000_media_type_copper) {		phy->type               = e1000_phy_none;		goto out;	} else {		func->power_up_phy      = e1000_power_up_phy_copper;		func->power_down_phy    = e1000_power_down_phy_copper;	}	phy->addr                       = 1;	phy->autoneg_mask               = AUTONEG_ADVERTISE_SPEED_DEFAULT;	phy->reset_delay_us             = 10000;	phy->type                       = e1000_phy_m88;	/* Function Pointers */	func->check_polarity            = e1000_check_polarity_m88;	func->commit_phy                = e1000_phy_sw_reset_generic;	func->force_speed_duplex        = e1000_phy_force_speed_duplex_82543;	func->get_cable_length          = e1000_get_cable_length_m88;	func->get_cfg_done              = e1000_get_cfg_done_generic;	func->read_phy_reg              = (hw->mac.type == e1000_82543)	                                  ? e1000_read_phy_reg_82543	                                  : e1000_read_phy_reg_m88;	func->reset_phy                 = (hw->mac.type == e1000_82543)	                                  ? e1000_phy_hw_reset_82543	                                  : e1000_phy_hw_reset_generic;	func->write_phy_reg             = (hw->mac.type == e1000_82543)	                                  ? e1000_write_phy_reg_82543	                                  : e1000_write_phy_reg_m88;	func->get_phy_info              = e1000_get_phy_info_m88;	/*	 * The external PHY of the 82543 can be in a funky state.	 * Resetting helps us read the PHY registers for acquiring	 * the PHY ID.	 */	if (!e1000_init_phy_disabled_82543(hw)) {		ret_val = e1000_phy_hw_reset(hw);		if (ret_val) {			DEBUGOUT("Resetting PHY during init failed.\n");			goto out;		}		msec_delay(20);	}	ret_val = e1000_get_phy_id(hw);	if (ret_val)		goto out;	/* Verify phy id */	switch (hw->mac.type) {	case e1000_82543:		if (phy->id != M88E1000_E_PHY_ID) {			ret_val = -E1000_ERR_PHY;			goto out;		}		break;	case e1000_82544:		if (phy->id != M88E1000_I_PHY_ID) {			ret_val = -E1000_ERR_PHY;			goto out;		}		break;	default:		ret_val = -E1000_ERR_PHY;		goto out;		break;	}out:	return ret_val;}/** *  e1000_init_nvm_params_82543 - Init NVM func ptrs. *  @hw: pointer to the HW structure * *  This is a function pointer entry point called by the api module. **/static s32 e1000_init_nvm_params_82543(struct e1000_hw *hw){	struct e1000_nvm_info *nvm = &hw->nvm;	struct e1000_functions *func = &hw->func;	DEBUGFUNC("e1000_init_nvm_params_82543");	nvm->type               = e1000_nvm_eeprom_microwire;	nvm->word_size          = 64;	nvm->delay_usec         = 50;	nvm->address_bits       =  6;	nvm->opcode_bits        =  3;	/* Function Pointers */	func->read_nvm          = e1000_read_nvm_microwire;	func->update_nvm        = e1000_update_nvm_checksum_generic;	func->valid_led_default = e1000_valid_led_default_generic;	func->validate_nvm      = e1000_validate_nvm_checksum_generic;	func->write_nvm         = e1000_write_nvm_microwire;	return E1000_SUCCESS;}/** *  e1000_init_mac_params_82543 - Init MAC func ptrs. *  @hw: pointer to the HW structure * *  This is a function pointer entry point called by the api module. **/static s32 e1000_init_mac_params_82543(struct e1000_hw *hw){	struct e1000_mac_info *mac = &hw->mac;	struct e1000_functions *func = &hw->func;	s32 ret_val;	DEBUGFUNC("e1000_init_mac_params_82543");	/* Set media type */	switch (hw->device_id) {	case E1000_DEV_ID_82543GC_FIBER:	case E1000_DEV_ID_82544EI_FIBER:		hw->phy.media_type = e1000_media_type_fiber;		break;	default:		hw->phy.media_type = e1000_media_type_copper;		break;	}	/* Set mta register count */	mac->mta_reg_count = 128;	/* Set rar entry count */	mac->rar_entry_count = E1000_RAR_ENTRIES;	/* Function pointers */	/* bus type/speed/width */	func->get_bus_info = e1000_get_bus_info_pci_generic;	/* reset */	func->reset_hw = e1000_reset_hw_82543;	/* hw initialization */	func->init_hw = e1000_init_hw_82543;	/* link setup */	func->setup_link = e1000_setup_link_82543;	/* physical interface setup */	func->setup_physical_interface =	        (hw->phy.media_type == e1000_media_type_copper)	                ? e1000_setup_copper_link_82543	                : e1000_setup_fiber_link_82543;	/* check for link */	func->check_for_link =	        (hw->phy.media_type == e1000_media_type_copper)	                ? e1000_check_for_copper_link_82543	                : e1000_check_for_fiber_link_82543;	/* link info */	func->get_link_up_info =	        (hw->phy.media_type == e1000_media_type_copper)	                ? e1000_get_speed_and_duplex_copper_generic	                : e1000_get_speed_and_duplex_fiber_serdes_generic;	/* multicast address update */	func->update_mc_addr_list = e1000_update_mc_addr_list_generic;	/* writing VFTA */	func->write_vfta = e1000_write_vfta_82543;	/* clearing VFTA */	func->clear_vfta = e1000_clear_vfta_generic;	/* setting MTA */	func->mta_set = e1000_mta_set_82543;	/* turn on/off LED */	func->led_on = e1000_led_on_82543;	func->led_off = e1000_led_off_82543;	/* remove device */	func->remove_device = e1000_remove_device_generic;	/* clear hardware counters */	func->clear_hw_cntrs = e1000_clear_hw_cntrs_82543;	hw->dev_spec_size = sizeof(struct e1000_dev_spec_82543);	/* Device-specific structure allocation */	ret_val = e1000_alloc_zeroed_dev_spec_struct(hw, hw->dev_spec_size);	if (ret_val)		goto out;	/* Set tbi compatibility */	if ((hw->mac.type != e1000_82543) ||	    (hw->phy.media_type == e1000_media_type_fiber))		e1000_set_tbi_compatibility_82543(hw, FALSE);out:	return ret_val;}/** *  e1000_init_function_pointers_82543 - Init func ptrs. *  @hw: pointer to the HW structure * *  The only function explicitly called by the api module to initialize *  all function pointers and parameters. **/void e1000_init_function_pointers_82543(struct e1000_hw *hw){	DEBUGFUNC("e1000_init_function_pointers_82543");	hw->func.init_mac_params = e1000_init_mac_params_82543;	hw->func.init_nvm_params = e1000_init_nvm_params_82543;	hw->func.init_phy_params = e1000_init_phy_params_82543;}/** *  e1000_tbi_compatibility_enabled_82543 - Returns TBI compat status *  @hw: pointer to the HW structure * *  Returns the curent status of 10-bit Interface (TBI) compatibility *  (enabled/disabled). **/static bool e1000_tbi_compatibility_enabled_82543(struct e1000_hw *hw){	struct e1000_dev_spec_82543 *dev_spec;	bool state = FALSE;	DEBUGFUNC("e1000_tbi_compatibility_enabled_82543");	if (hw->mac.type != e1000_82543) {		DEBUGOUT("TBI compatibility workaround for 82543 only.\n");		goto out;	}	dev_spec = (struct e1000_dev_spec_82543 *)hw->dev_spec;	if (!dev_spec) {		DEBUGOUT("dev_spec pointer is set to NULL.\n");		goto out;	}	state = (dev_spec->tbi_compatibility & TBI_COMPAT_ENABLED)	        ? TRUE : FALSE;out:	return state;}/** *  e1000_set_tbi_compatibility_82543 - Set TBI compatibility *  @hw: pointer to the HW structure *  @state: enable/disable TBI compatibility * *  Enables or disabled 10-bit Interface (TBI) compatibility. **/void e1000_set_tbi_compatibility_82543(struct e1000_hw *hw, bool state){	struct e1000_dev_spec_82543 *dev_spec;	DEBUGFUNC("e1000_set_tbi_compatibility_82543");	if (hw->mac.type != e1000_82543) {		DEBUGOUT("TBI compatibility workaround for 82543 only.\n");		goto out;	}	dev_spec = (struct e1000_dev_spec_82543 *)hw->dev_spec;	if (!dev_spec) {		DEBUGOUT("dev_spec pointer is set to NULL.\n");		goto out;	}	if (state)		dev_spec->tbi_compatibility |= TBI_COMPAT_ENABLED;	else		dev_spec->tbi_compatibility &= ~TBI_COMPAT_ENABLED;out:	return;}/** *  e1000_tbi_sbp_enabled_82543 - Returns TBI SBP status *  @hw: pointer to the HW structure * *  Returns the curent status of 10-bit Interface (TBI) store bad packet (SBP) *  (enabled/disabled). **/bool e1000_tbi_sbp_enabled_82543(struct e1000_hw *hw){	struct e1000_dev_spec_82543 *dev_spec;	bool state = FALSE;	DEBUGFUNC("e1000_tbi_sbp_enabled_82543");	if (hw->mac.type != e1000_82543) {		DEBUGOUT("TBI compatibility workaround for 82543 only.\n");		goto out;	}	dev_spec = (struct e1000_dev_spec_82543 *)hw->dev_spec;	if (!dev_spec) {		DEBUGOUT("dev_spec pointer is set to NULL.\n");		goto out;	}	state = (dev_spec->tbi_compatibility & TBI_SBP_ENABLED)	        ? TRUE : FALSE;out:	return state;}/** *  e1000_set_tbi_sbp_82543 - Set TBI SBP *  @hw: pointer to the HW structure *  @state: enable/disable TBI store bad packet * *  Enables or disabled 10-bit Interface (TBI) store bad packet (SBP). **/static void e1000_set_tbi_sbp_82543(struct e1000_hw *hw, bool state){	struct e1000_dev_spec_82543 *dev_spec;	DEBUGFUNC("e1000_set_tbi_sbp_82543");	dev_spec = (struct e1000_dev_spec_82543 *)hw->dev_spec;	if (state && e1000_tbi_compatibility_enabled_82543(hw))		dev_spec->tbi_compatibility |= TBI_SBP_ENABLED;	else		dev_spec->tbi_compatibility &= ~TBI_SBP_ENABLED;	return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -