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

📄 e1000_api.c

📁 e1000 8.0.1 version.最新的e1000 linux下的驱动
💻 C
📖 第 1 页 / 共 3 页
字号:
/*******************************************************************************  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*******************************************************************************/#include "e1000_api.h"#include "e1000_mac.h"#include "e1000_nvm.h"#include "e1000_phy.h"/** *  e1000_init_mac_params - Initialize MAC function pointers *  @hw: pointer to the HW structure * *  This function initializes the function pointers for the MAC *  set of functions.  Called by drivers or by e1000_setup_init_funcs. **/s32 e1000_init_mac_params(struct e1000_hw *hw){	s32 ret_val = E1000_SUCCESS;	if (hw->mac.ops.init_params) {		ret_val = hw->mac.ops.init_params(hw);		if (ret_val) {			DEBUGOUT("MAC Initialization Error\n");			goto out;		}	} else {		DEBUGOUT("mac.init_mac_params was NULL\n");		ret_val = -E1000_ERR_CONFIG;	}out:	return ret_val;}/** *  e1000_init_nvm_params - Initialize NVM function pointers *  @hw: pointer to the HW structure * *  This function initializes the function pointers for the NVM *  set of functions.  Called by drivers or by e1000_setup_init_funcs. **/s32 e1000_init_nvm_params(struct e1000_hw *hw){	s32 ret_val = E1000_SUCCESS;	if (hw->nvm.ops.init_params) {		ret_val = hw->nvm.ops.init_params(hw);		if (ret_val) {			DEBUGOUT("NVM Initialization Error\n");			goto out;		}	} else {		DEBUGOUT("nvm.init_nvm_params was NULL\n");		ret_val = -E1000_ERR_CONFIG;	}out:	return ret_val;}/** *  e1000_init_phy_params - Initialize PHY function pointers *  @hw: pointer to the HW structure * *  This function initializes the function pointers for the PHY *  set of functions.  Called by drivers or by e1000_setup_init_funcs. **/s32 e1000_init_phy_params(struct e1000_hw *hw){	s32 ret_val = E1000_SUCCESS;	if (hw->phy.ops.init_params) {		ret_val = hw->phy.ops.init_params(hw);		if (ret_val) {			DEBUGOUT("PHY Initialization Error\n");			goto out;		}	} else {		DEBUGOUT("phy.init_phy_params was NULL\n");		ret_val =  -E1000_ERR_CONFIG;	}out:	return ret_val;}/** *  e1000_set_mac_type - Sets MAC type *  @hw: pointer to the HW structure * *  This function sets the mac type of the adapter based on the *  device ID stored in the hw structure. *  MUST BE FIRST FUNCTION CALLED (explicitly or through *  e1000_setup_init_funcs()). **/s32 e1000_set_mac_type(struct e1000_hw *hw){	struct e1000_mac_info *mac = &hw->mac;	s32 ret_val = E1000_SUCCESS;	DEBUGFUNC("e1000_set_mac_type");	switch (hw->device_id) {	case E1000_DEV_ID_82542:		mac->type = e1000_82542;		break;	case E1000_DEV_ID_82543GC_FIBER:	case E1000_DEV_ID_82543GC_COPPER:		mac->type = e1000_82543;		break;	case E1000_DEV_ID_82544EI_COPPER:	case E1000_DEV_ID_82544EI_FIBER:	case E1000_DEV_ID_82544GC_COPPER:	case E1000_DEV_ID_82544GC_LOM:		mac->type = e1000_82544;		break;	case E1000_DEV_ID_82540EM:	case E1000_DEV_ID_82540EM_LOM:	case E1000_DEV_ID_82540EP:	case E1000_DEV_ID_82540EP_LOM:	case E1000_DEV_ID_82540EP_LP:		mac->type = e1000_82540;		break;	case E1000_DEV_ID_82545EM_COPPER:	case E1000_DEV_ID_82545EM_FIBER:		mac->type = e1000_82545;		break;	case E1000_DEV_ID_82545GM_COPPER:	case E1000_DEV_ID_82545GM_FIBER:	case E1000_DEV_ID_82545GM_SERDES:		mac->type = e1000_82545_rev_3;		break;	case E1000_DEV_ID_82546EB_COPPER:	case E1000_DEV_ID_82546EB_FIBER:	case E1000_DEV_ID_82546EB_QUAD_COPPER:		mac->type = e1000_82546;		break;	case E1000_DEV_ID_82546GB_COPPER:	case E1000_DEV_ID_82546GB_FIBER:	case E1000_DEV_ID_82546GB_SERDES:	case E1000_DEV_ID_82546GB_PCIE:	case E1000_DEV_ID_82546GB_QUAD_COPPER:	case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:		mac->type = e1000_82546_rev_3;		break;	case E1000_DEV_ID_82541EI:	case E1000_DEV_ID_82541EI_MOBILE:	case E1000_DEV_ID_82541ER_LOM:		mac->type = e1000_82541;		break;	case E1000_DEV_ID_82541ER:	case E1000_DEV_ID_82541GI:	case E1000_DEV_ID_82541GI_LF:	case E1000_DEV_ID_82541GI_MOBILE:		mac->type = e1000_82541_rev_2;		break;	case E1000_DEV_ID_82547EI:	case E1000_DEV_ID_82547EI_MOBILE:		mac->type = e1000_82547;		break;	case E1000_DEV_ID_82547GI:		mac->type = e1000_82547_rev_2;		break;	default:		/* Should never have loaded on this device */		ret_val = -E1000_ERR_MAC_INIT;		break;	}	return ret_val;}/** *  e1000_setup_init_funcs - Initializes function pointers *  @hw: pointer to the HW structure *  @init_device: TRUE will initialize the rest of the function pointers *                 getting the device ready for use.  FALSE will only set *                 MAC type and the function pointers for the other init *                 functions.  Passing FALSE will not generate any hardware *                 reads or writes. * *  This function must be called by a driver in order to use the rest *  of the 'shared' code files. Called by drivers only. **/s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device){	s32 ret_val;	/* Can't do much good without knowing the MAC type. */	ret_val = e1000_set_mac_type(hw);	if (ret_val) {		DEBUGOUT("ERROR: MAC type could not be set properly.\n");		goto out;	}	if (!hw->hw_addr) {		DEBUGOUT("ERROR: Registers not mapped\n");		ret_val = -E1000_ERR_CONFIG;		goto out;	}	/*	 * Init function pointers to generic implementations. We do this first	 * allowing a driver module to override it afterward.	 */	e1000_init_mac_ops_generic(hw);	e1000_init_phy_ops_generic(hw);	e1000_init_nvm_ops_generic(hw);	/*	 * Set up the init function pointers. These are functions within the	 * adapter family file that sets up function pointers for the rest of	 * the functions in that family.	 */	switch (hw->mac.type) {	case e1000_82542:		e1000_init_function_pointers_82542(hw);		break;	case e1000_82543:	case e1000_82544:		e1000_init_function_pointers_82543(hw);		break;	case e1000_82540:	case e1000_82545:	case e1000_82545_rev_3:	case e1000_82546:	case e1000_82546_rev_3:		e1000_init_function_pointers_82540(hw);		break;	case e1000_82541:	case e1000_82541_rev_2:	case e1000_82547:	case e1000_82547_rev_2:		e1000_init_function_pointers_82541(hw);		break;	default:		DEBUGOUT("Hardware not supported\n");		ret_val = -E1000_ERR_CONFIG;		break;	}	/*	 * Initialize the rest of the function pointers. These require some	 * register reads/writes in some cases.	 */	if (!(ret_val) && init_device) {		ret_val = e1000_init_mac_params(hw);		if (ret_val)			goto out;		ret_val = e1000_init_nvm_params(hw);		if (ret_val)			goto out;		ret_val = e1000_init_phy_params(hw);		if (ret_val)			goto out;	}out:	return ret_val;}/** *  e1000_remove_device - Free device specific structure *  @hw: pointer to the HW structure * *  If a device specific structure was allocated, this function will *  free it. This is a function pointer entry point called by drivers. **/void e1000_remove_device(struct e1000_hw *hw){	if (hw->mac.ops.remove_device)		hw->mac.ops.remove_device(hw);}/** *  e1000_get_bus_info - Obtain bus information for adapter *  @hw: pointer to the HW structure * *  This will obtain information about the HW bus for which the *  adapter is attached and stores it in the hw structure. This is a *  function pointer entry point called by drivers. **/s32 e1000_get_bus_info(struct e1000_hw *hw){	if (hw->mac.ops.get_bus_info)		return hw->mac.ops.get_bus_info(hw);	return E1000_SUCCESS;}/** *  e1000_clear_vfta - Clear VLAN filter table *  @hw: pointer to the HW structure * *  This clears the VLAN filter table on the adapter. This is a function *  pointer entry point called by drivers. **/void e1000_clear_vfta(struct e1000_hw *hw){	if (hw->mac.ops.clear_vfta)		hw->mac.ops.clear_vfta (hw);}/** *  e1000_write_vfta - Write value to VLAN filter table *  @hw: pointer to the HW structure *  @offset: the 32-bit offset in which to write the value to. *  @value: the 32-bit value to write at location offset. * *  This writes a 32-bit value to a 32-bit offset in the VLAN filter *  table. This is a function pointer entry point called by drivers. **/void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value){	if (hw->mac.ops.write_vfta)		hw->mac.ops.write_vfta(hw, offset, value);}/** *  e1000_update_mc_addr_list - 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 * *  Updates the Receive Address Registers and Multicast Table Array. *  The caller must have a packed mc_addr_list of multicast addresses. *  The parameter rar_count will usually be hw->mac.rar_entry_count *  unless there are workarounds that change this.  Currently no func pointer *  exists and all implementations are handled in the generic version of this *  function. **/void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,                               u32 mc_addr_count, u32 rar_used_count,                               u32 rar_count){	if (hw->mac.ops.update_mc_addr_list)		hw->mac.ops.update_mc_addr_list(hw,		                                mc_addr_list,		                                mc_addr_count,		                                rar_used_count,		                                rar_count);}/** *  e1000_force_mac_fc - Force MAC flow control *  @hw: pointer to the HW structure *

⌨️ 快捷键说明

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