The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/em/e1000_api.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*******************************************************************************
    2 
    3   Copyright (c) 2001-2007, Intel Corporation 
    4   All rights reserved.
    5   
    6   Redistribution and use in source and binary forms, with or without 
    7   modification, are permitted provided that the following conditions are met:
    8   
    9    1. Redistributions of source code must retain the above copyright notice, 
   10       this list of conditions and the following disclaimer.
   11   
   12    2. Redistributions in binary form must reproduce the above copyright 
   13       notice, this list of conditions and the following disclaimer in the 
   14       documentation and/or other materials provided with the distribution.
   15   
   16    3. Neither the name of the Intel Corporation nor the names of its 
   17       contributors may be used to endorse or promote products derived from 
   18       this software without specific prior written permission.
   19   
   20   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   21   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
   22   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
   23   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
   24   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
   25   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
   26   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
   27   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
   28   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
   29   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   30   POSSIBILITY OF SUCH DAMAGE.
   31 
   32 *******************************************************************************/
   33 /* $FreeBSD$ */
   34 
   35 #include "e1000_api.h"
   36 #include "e1000_mac.h"
   37 #include "e1000_nvm.h"
   38 #include "e1000_phy.h"
   39 
   40 #ifndef NO_82542_SUPPORT
   41 extern void    e1000_init_function_pointers_82542(struct e1000_hw *hw);
   42 #endif
   43 extern void    e1000_init_function_pointers_82543(struct e1000_hw *hw);
   44 extern void    e1000_init_function_pointers_82540(struct e1000_hw *hw);
   45 extern void    e1000_init_function_pointers_82571(struct e1000_hw *hw);
   46 extern void    e1000_init_function_pointers_82541(struct e1000_hw *hw);
   47 extern void    e1000_init_function_pointers_80003es2lan(struct e1000_hw *hw);
   48 extern void    e1000_init_function_pointers_ich8lan(struct e1000_hw *hw);
   49 extern void    e1000_init_function_pointers_82575(struct e1000_hw *hw);
   50 
   51 /**
   52  *  e1000_init_mac_params - Initialize MAC function pointers
   53  *  @hw: pointer to the HW structure
   54  *
   55  *  This function initializes the function pointers for the MAC
   56  *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
   57  **/
   58 s32 e1000_init_mac_params(struct e1000_hw *hw)
   59 {
   60         s32 ret_val = E1000_SUCCESS;
   61 
   62         if (hw->func.init_mac_params) {
   63                 ret_val = hw->func.init_mac_params(hw);
   64                 if (ret_val) {
   65                         DEBUGOUT("MAC Initialization Error\n");
   66                         goto out;
   67                 }
   68         } else {
   69                 DEBUGOUT("mac.init_mac_params was NULL\n");
   70                 ret_val = -E1000_ERR_CONFIG;
   71         }
   72 
   73 out:
   74         return ret_val;
   75 }
   76 
   77 /**
   78  *  e1000_init_nvm_params - Initialize NVM function pointers
   79  *  @hw: pointer to the HW structure
   80  *
   81  *  This function initializes the function pointers for the NVM
   82  *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
   83  **/
   84 s32 e1000_init_nvm_params(struct e1000_hw *hw)
   85 {
   86         s32 ret_val = E1000_SUCCESS;
   87 
   88         if (hw->func.init_nvm_params) {
   89                 ret_val = hw->func.init_nvm_params(hw);
   90                 if (ret_val) {
   91                         DEBUGOUT("NVM Initialization Error\n");
   92                         goto out;
   93                 }
   94         } else {
   95                 DEBUGOUT("nvm.init_nvm_params was NULL\n");
   96                 ret_val = -E1000_ERR_CONFIG;
   97         }
   98 
   99 out:
  100         return ret_val;
  101 }
  102 
  103 /**
  104  *  e1000_init_phy_params - Initialize PHY function pointers
  105  *  @hw: pointer to the HW structure
  106  *
  107  *  This function initializes the function pointers for the PHY
  108  *  set of functions.  Called by drivers or by e1000_setup_init_funcs.
  109  **/
  110 s32 e1000_init_phy_params(struct e1000_hw *hw)
  111 {
  112         s32 ret_val = E1000_SUCCESS;
  113 
  114         if (hw->func.init_phy_params) {
  115                 ret_val = hw->func.init_phy_params(hw);
  116                 if (ret_val) {
  117                         DEBUGOUT("PHY Initialization Error\n");
  118                         goto out;
  119                 }
  120         } else {
  121                 DEBUGOUT("phy.init_phy_params was NULL\n");
  122                 ret_val =  -E1000_ERR_CONFIG;
  123         }
  124 
  125 out:
  126         return ret_val;
  127 }
  128 
  129 /**
  130  *  e1000_set_mac_type - Sets MAC type
  131  *  @hw: pointer to the HW structure
  132  *
  133  *  This function sets the mac type of the adapter based on the
  134  *  device ID stored in the hw structure.
  135  *  MUST BE FIRST FUNCTION CALLED (explicitly or through
  136  *  e1000_setup_init_funcs()).
  137  **/
  138 s32 e1000_set_mac_type(struct e1000_hw *hw)
  139 {
  140         struct e1000_mac_info *mac = &hw->mac;
  141         s32 ret_val = E1000_SUCCESS;
  142 
  143         DEBUGFUNC("e1000_set_mac_type");
  144 
  145         switch (hw->device_id) {
  146 #ifndef NO_82542_SUPPORT
  147         case E1000_DEV_ID_82542:
  148                 mac->type = e1000_82542;
  149                 break;
  150 #endif
  151         case E1000_DEV_ID_82543GC_FIBER:
  152         case E1000_DEV_ID_82543GC_COPPER:
  153                 mac->type = e1000_82543;
  154                 break;
  155         case E1000_DEV_ID_82544EI_COPPER:
  156         case E1000_DEV_ID_82544EI_FIBER:
  157         case E1000_DEV_ID_82544GC_COPPER:
  158         case E1000_DEV_ID_82544GC_LOM:
  159                 mac->type = e1000_82544;
  160                 break;
  161         case E1000_DEV_ID_82540EM:
  162         case E1000_DEV_ID_82540EM_LOM:
  163         case E1000_DEV_ID_82540EP:
  164         case E1000_DEV_ID_82540EP_LOM:
  165         case E1000_DEV_ID_82540EP_LP:
  166                 mac->type = e1000_82540;
  167                 break;
  168         case E1000_DEV_ID_82545EM_COPPER:
  169         case E1000_DEV_ID_82545EM_FIBER:
  170                 mac->type = e1000_82545;
  171                 break;
  172         case E1000_DEV_ID_82545GM_COPPER:
  173         case E1000_DEV_ID_82545GM_FIBER:
  174         case E1000_DEV_ID_82545GM_SERDES:
  175                 mac->type = e1000_82545_rev_3;
  176                 break;
  177         case E1000_DEV_ID_82546EB_COPPER:
  178         case E1000_DEV_ID_82546EB_FIBER:
  179         case E1000_DEV_ID_82546EB_QUAD_COPPER:
  180                 mac->type = e1000_82546;
  181                 break;
  182         case E1000_DEV_ID_82546GB_COPPER:
  183         case E1000_DEV_ID_82546GB_FIBER:
  184         case E1000_DEV_ID_82546GB_SERDES:
  185         case E1000_DEV_ID_82546GB_PCIE:
  186         case E1000_DEV_ID_82546GB_QUAD_COPPER:
  187         case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3:
  188                 mac->type = e1000_82546_rev_3;
  189                 break;
  190         case E1000_DEV_ID_82541EI:
  191         case E1000_DEV_ID_82541EI_MOBILE:
  192         case E1000_DEV_ID_82541ER_LOM:
  193                 mac->type = e1000_82541;
  194                 break;
  195         case E1000_DEV_ID_82541ER:
  196         case E1000_DEV_ID_82541GI:
  197         case E1000_DEV_ID_82541GI_LF:
  198         case E1000_DEV_ID_82541GI_MOBILE:
  199                 mac->type = e1000_82541_rev_2;
  200                 break;
  201         case E1000_DEV_ID_82547EI:
  202         case E1000_DEV_ID_82547EI_MOBILE:
  203                 mac->type = e1000_82547;
  204                 break;
  205         case E1000_DEV_ID_82547GI:
  206                 mac->type = e1000_82547_rev_2;
  207                 break;
  208         case E1000_DEV_ID_82571EB_COPPER:
  209         case E1000_DEV_ID_82571EB_FIBER:
  210         case E1000_DEV_ID_82571EB_SERDES:
  211         case E1000_DEV_ID_82571EB_SERDES_DUAL:
  212         case E1000_DEV_ID_82571EB_SERDES_QUAD:
  213         case E1000_DEV_ID_82571EB_QUAD_COPPER:
  214         case E1000_DEV_ID_82571PT_QUAD_COPPER:
  215         case E1000_DEV_ID_82571EB_QUAD_FIBER:
  216         case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
  217                 mac->type = e1000_82571;
  218                 break;
  219         case E1000_DEV_ID_82572EI:
  220         case E1000_DEV_ID_82572EI_COPPER:
  221         case E1000_DEV_ID_82572EI_FIBER:
  222         case E1000_DEV_ID_82572EI_SERDES:
  223                 mac->type = e1000_82572;
  224                 break;
  225         case E1000_DEV_ID_82573E:
  226         case E1000_DEV_ID_82573E_IAMT:
  227         case E1000_DEV_ID_82573L:
  228                 mac->type = e1000_82573;
  229                 break;
  230         case E1000_DEV_ID_80003ES2LAN_COPPER_DPT:
  231         case E1000_DEV_ID_80003ES2LAN_SERDES_DPT:
  232         case E1000_DEV_ID_80003ES2LAN_COPPER_SPT:
  233         case E1000_DEV_ID_80003ES2LAN_SERDES_SPT:
  234                 mac->type = e1000_80003es2lan;
  235                 break;
  236         case E1000_DEV_ID_ICH8_IFE:
  237         case E1000_DEV_ID_ICH8_IFE_GT:
  238         case E1000_DEV_ID_ICH8_IFE_G:
  239         case E1000_DEV_ID_ICH8_IGP_M:
  240         case E1000_DEV_ID_ICH8_IGP_M_AMT:
  241         case E1000_DEV_ID_ICH8_IGP_AMT:
  242         case E1000_DEV_ID_ICH8_IGP_C:
  243                 mac->type = e1000_ich8lan;
  244                 break;
  245         case E1000_DEV_ID_ICH9_IFE:
  246         case E1000_DEV_ID_ICH9_IFE_GT:
  247         case E1000_DEV_ID_ICH9_IFE_G:
  248         case E1000_DEV_ID_ICH9_IGP_AMT:
  249         case E1000_DEV_ID_ICH9_IGP_C:
  250                 mac->type = e1000_ich9lan;
  251                 break;
  252         case E1000_DEV_ID_82575EB_COPPER:
  253         case E1000_DEV_ID_82575EB_FIBER_SERDES:
  254         case E1000_DEV_ID_82575GB_QUAD_COPPER:
  255                 mac->type = e1000_82575;
  256                 break;
  257         default:
  258                 /* Should never have loaded on this device */
  259                 ret_val = -E1000_ERR_MAC_INIT;
  260                 break;
  261         }
  262 
  263         return ret_val;
  264 }
  265 
  266 /**
  267  *  e1000_setup_init_funcs - Initializes function pointers
  268  *  @hw: pointer to the HW structure
  269  *  @init_device: TRUE will initialize the rest of the function pointers
  270  *                 getting the device ready for use.  FALSE will only set
  271  *                 MAC type and the function pointers for the other init
  272  *                 functions.  Passing FALSE will not generate any hardware
  273  *                 reads or writes.
  274  *
  275  *  This function must be called by a driver in order to use the rest
  276  *  of the 'shared' code files. Called by drivers only.
  277  **/
  278 s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device)
  279 {
  280         s32 ret_val;
  281 
  282         /* Can't do much good without knowing the MAC type. */
  283         ret_val = e1000_set_mac_type(hw);
  284         if (ret_val) {
  285                 DEBUGOUT("ERROR: MAC type could not be set properly.\n");
  286                 goto out;
  287         }
  288 
  289         if (!hw->hw_addr) {
  290                 DEBUGOUT("ERROR: Registers not mapped\n");
  291                 ret_val = -E1000_ERR_CONFIG;
  292                 goto out;
  293         }
  294 
  295         /*
  296          * Init some generic function pointers that are currently all pointing
  297          * to generic implementations. We do this first allowing a driver
  298          * module to override it afterwards.
  299          */
  300         hw->func.config_collision_dist = e1000_config_collision_dist_generic;
  301         hw->func.rar_set = e1000_rar_set_generic;
  302         hw->func.validate_mdi_setting = e1000_validate_mdi_setting_generic;
  303         hw->func.mng_host_if_write = e1000_mng_host_if_write_generic;
  304         hw->func.mng_write_cmd_header = e1000_mng_write_cmd_header_generic;
  305         hw->func.mng_enable_host_if = e1000_mng_enable_host_if_generic;
  306         hw->func.wait_autoneg = e1000_wait_autoneg_generic;
  307         hw->func.reload_nvm = e1000_reload_nvm_generic;
  308 
  309         /*
  310          * Set up the init function pointers. These are functions within the
  311          * adapter family file that sets up function pointers for the rest of
  312          * the functions in that family.
  313          */
  314         switch (hw->mac.type) {
  315 #ifndef NO_82542_SUPPORT
  316         case e1000_82542:
  317                 e1000_init_function_pointers_82542(hw);
  318                 break;
  319 #endif
  320         case e1000_82543:
  321         case e1000_82544:
  322                 e1000_init_function_pointers_82543(hw);
  323                 break;
  324         case e1000_82540:
  325         case e1000_82545:
  326         case e1000_82545_rev_3:
  327         case e1000_82546:
  328         case e1000_82546_rev_3:
  329                 e1000_init_function_pointers_82540(hw);
  330                 break;
  331         case e1000_82541:
  332         case e1000_82541_rev_2:
  333         case e1000_82547:
  334         case e1000_82547_rev_2:
  335                 e1000_init_function_pointers_82541(hw);
  336                 break;
  337         case e1000_82571:
  338         case e1000_82572:
  339         case e1000_82573:
  340                 e1000_init_function_pointers_82571(hw);
  341                 break;
  342         case e1000_80003es2lan:
  343                 e1000_init_function_pointers_80003es2lan(hw);
  344                 break;
  345         case e1000_ich8lan:
  346         case e1000_ich9lan:
  347                 e1000_init_function_pointers_ich8lan(hw);
  348                 break;
  349         case e1000_82575:
  350                 e1000_init_function_pointers_82575(hw);
  351                 break;
  352         default:
  353                 DEBUGOUT("Hardware not supported\n");
  354                 ret_val = -E1000_ERR_CONFIG;
  355                 break;
  356         }
  357 
  358         /*
  359          * Initialize the rest of the function pointers. These require some
  360          * register reads/writes in some cases.
  361          */
  362         if (!(ret_val) && init_device) {
  363                 ret_val = e1000_init_mac_params(hw);
  364                 if (ret_val)
  365                         goto out;
  366 
  367                 ret_val = e1000_init_nvm_params(hw);
  368                 if (ret_val)
  369                         goto out;
  370 
  371                 ret_val = e1000_init_phy_params(hw);
  372                 if (ret_val)
  373                         goto out;
  374 
  375         }
  376 
  377 out:
  378         return ret_val;
  379 }
  380 
  381 /**
  382  *  e1000_remove_device - Free device specific structure
  383  *  @hw: pointer to the HW structure
  384  *
  385  *  If a device specific structure was allocated, this function will
  386  *  free it. This is a function pointer entry point called by drivers.
  387  **/
  388 void e1000_remove_device(struct e1000_hw *hw)
  389 {
  390         if (hw->func.remove_device)
  391                 hw->func.remove_device(hw);
  392 }
  393 
  394 /**
  395  *  e1000_get_bus_info - Obtain bus information for adapter
  396  *  @hw: pointer to the HW structure
  397  *
  398  *  This will obtain information about the HW bus for which the
  399  *  adaper is attached and stores it in the hw structure. This is a
  400  *  function pointer entry point called by drivers.
  401  **/
  402 s32 e1000_get_bus_info(struct e1000_hw *hw)
  403 {
  404         if (hw->func.get_bus_info)
  405                 return hw->func.get_bus_info(hw);
  406 
  407         return E1000_SUCCESS;
  408 }
  409 
  410 /**
  411  *  e1000_clear_vfta - Clear VLAN filter table
  412  *  @hw: pointer to the HW structure
  413  *
  414  *  This clears the VLAN filter table on the adapter. This is a function
  415  *  pointer entry point called by drivers.
  416  **/
  417 void e1000_clear_vfta(struct e1000_hw *hw)
  418 {
  419         if (hw->func.clear_vfta)
  420                 hw->func.clear_vfta (hw);
  421 }
  422 
  423 /**
  424  *  e1000_write_vfta - Write value to VLAN filter table
  425  *  @hw: pointer to the HW structure
  426  *  @offset: the 32-bit offset in which to write the value to.
  427  *  @value: the 32-bit value to write at location offset.
  428  *
  429  *  This writes a 32-bit value to a 32-bit offset in the VLAN filter
  430  *  table. This is a function pointer entry point called by drivers.
  431  **/
  432 void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value)
  433 {
  434         if (hw->func.write_vfta)
  435                 hw->func.write_vfta(hw, offset, value);
  436 }
  437 
  438 /**
  439  *  e1000_update_mc_addr_list - Update Multicast addresses
  440  *  @hw: pointer to the HW structure
  441  *  @mc_addr_list: array of multicast addresses to program
  442  *  @mc_addr_count: number of multicast addresses to program
  443  *  @rar_used_count: the first RAR register free to program
  444  *  @rar_count: total number of supported Receive Address Registers
  445  *
  446  *  Updates the Receive Address Registers and Multicast Table Array.
  447  *  The caller must have a packed mc_addr_list of multicast addresses.
  448  *  The parameter rar_count will usually be hw->mac.rar_entry_count
  449  *  unless there are workarounds that change this.  Currently no func pointer
  450  *  exists and all implementations are handled in the generic version of this
  451  *  function.
  452  **/
  453 void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
  454                                u32 mc_addr_count, u32 rar_used_count,
  455                                u32 rar_count)
  456 {
  457         if (hw->func.update_mc_addr_list)
  458                 hw->func.update_mc_addr_list(hw,
  459                                              mc_addr_list,
  460                                              mc_addr_count,
  461                                              rar_used_count,
  462                                              rar_count);
  463 }
  464 
  465 /**
  466  *  e1000_force_mac_fc - Force MAC flow control
  467  *  @hw: pointer to the HW structure
  468  *
  469  *  Force the MAC's flow control settings. Currently no func pointer exists
  470  *  and all implementations are handled in the generic version of this
  471  *  function.
  472  **/
  473 s32 e1000_force_mac_fc(struct e1000_hw *hw)
  474 {
  475         return e1000_force_mac_fc_generic(hw);
  476 }
  477 
  478 /**
  479  *  e1000_check_for_link - Check/Store link connection
  480  *  @hw: pointer to the HW structure
  481  *
  482  *  This checks the link condition of the adapter and stores the
  483  *  results in the hw->mac structure. This is a function pointer entry
  484  *  point called by drivers.
  485  **/
  486 s32 e1000_check_for_link(struct e1000_hw *hw)
  487 {
  488         if (hw->func.check_for_link)
  489                 return hw->func.check_for_link(hw);
  490 
  491         return -E1000_ERR_CONFIG;
  492 }
  493 
  494 /**
  495  *  e1000_check_mng_mode - Check management mode
  496  *  @hw: pointer to the HW structure
  497  *
  498  *  This checks if the adapter has manageability enabled.
  499  *  This is a function pointer entry point called by drivers.
  500  **/
  501 bool e1000_check_mng_mode(struct e1000_hw *hw)
  502 {
  503         if (hw->func.check_mng_mode)
  504                 return hw->func.check_mng_mode(hw);
  505 
  506         return FALSE;
  507 }
  508 
  509 /**
  510  *  e1000_mng_write_dhcp_info - Writes DHCP info to host interface
  511  *  @hw: pointer to the HW structure
  512  *  @buffer: pointer to the host interface
  513  *  @length: size of the buffer
  514  *
  515  *  Writes the DHCP information to the host interface.
  516  **/
  517 s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length)
  518 {
  519         return e1000_mng_write_dhcp_info_generic(hw, buffer, length);
  520 }
  521 
  522 /**
  523  *  e1000_reset_hw - Reset hardware
  524  *  @hw: pointer to the HW structure
  525  *
  526  *  This resets the hardware into a known state. This is a function pointer
  527  *  entry point called by drivers.
  528  **/
  529 s32 e1000_reset_hw(struct e1000_hw *hw)
  530 {
  531         if (hw->func.reset_hw)
  532                 return hw->func.reset_hw(hw);
  533 
  534         return -E1000_ERR_CONFIG;
  535 }
  536 
  537 /**
  538  *  e1000_init_hw - Initialize hardware
  539  *  @hw: pointer to the HW structure
  540  *
  541  *  This inits the hardware readying it for operation. This is a function
  542  *  pointer entry point called by drivers.
  543  **/
  544 s32 e1000_init_hw(struct e1000_hw *hw)
  545 {
  546         if (hw->func.init_hw)
  547                 return hw->func.init_hw(hw);
  548 
  549         return -E1000_ERR_CONFIG;
  550 }
  551 
  552 /**
  553  *  e1000_setup_link - Configures link and flow control
  554  *  @hw: pointer to the HW structure
  555  *
  556  *  This configures link and flow control settings for the adapter. This
  557  *  is a function pointer entry point called by drivers. While modules can
  558  *  also call this, they probably call their own version of this function.
  559  **/
  560 s32 e1000_setup_link(struct e1000_hw *hw)
  561 {
  562         if (hw->func.setup_link)
  563                 return hw->func.setup_link(hw);
  564 
  565         return -E1000_ERR_CONFIG;
  566 }
  567 
  568 /**
  569  *  e1000_get_speed_and_duplex - Returns current speed and duplex
  570  *  @hw: pointer to the HW structure
  571  *  @speed: pointer to a 16-bit value to store the speed
  572  *  @duplex: pointer to a 16-bit value to store the duplex.
  573  *
  574  *  This returns the speed and duplex of the adapter in the two 'out'
  575  *  variables passed in. This is a function pointer entry point called
  576  *  by drivers.
  577  **/
  578 s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)
  579 {
  580         if (hw->func.get_link_up_info)
  581                 return hw->func.get_link_up_info(hw, speed, duplex);
  582 
  583         return -E1000_ERR_CONFIG;
  584 }
  585 
  586 /**
  587  *  e1000_setup_led - Configures SW controllable LED
  588  *  @hw: pointer to the HW structure
  589  *
  590  *  This prepares the SW controllable LED for use and saves the current state
  591  *  of the LED so it can be later restored. This is a function pointer entry
  592  *  point called by drivers.
  593  **/
  594 s32 e1000_setup_led(struct e1000_hw *hw)
  595 {
  596         if (hw->func.setup_led)
  597                 return hw->func.setup_led(hw);
  598 
  599         return E1000_SUCCESS;
  600 }
  601 
  602 /**
  603  *  e1000_cleanup_led - Restores SW controllable LED
  604  *  @hw: pointer to the HW structure
  605  *
  606  *  This restores the SW controllable LED to the value saved off by
  607  *  e1000_setup_led. This is a function pointer entry point called by drivers.
  608  **/
  609 s32 e1000_cleanup_led(struct e1000_hw *hw)
  610 {
  611         if (hw->func.cleanup_led)
  612                 return hw->func.cleanup_led(hw);
  613 
  614         return E1000_SUCCESS;
  615 }
  616 
  617 /**
  618  *  e1000_blink_led - Blink SW controllable LED
  619  *  @hw: pointer to the HW structure
  620  *
  621  *  This starts the adapter LED blinking. Request the LED to be setup first
  622  *  and cleaned up after. This is a function pointer entry point called by
  623  *  drivers.
  624  **/
  625 s32 e1000_blink_led(struct e1000_hw *hw)
  626 {
  627         if (hw->func.blink_led)
  628                 return hw->func.blink_led(hw);
  629 
  630         return E1000_SUCCESS;
  631 }
  632 
  633 /**
  634  *  e1000_led_on - Turn on SW controllable LED
  635  *  @hw: pointer to the HW structure
  636  *
  637  *  Turns the SW defined LED on. This is a function pointer entry point
  638  *  called by drivers.
  639  **/
  640 s32 e1000_led_on(struct e1000_hw *hw)
  641 {
  642         if (hw->func.led_on)
  643                 return hw->func.led_on(hw);
  644 
  645         return E1000_SUCCESS;
  646 }
  647 
  648 /**
  649  *  e1000_led_off - Turn off SW controllable LED
  650  *  @hw: pointer to the HW structure
  651  *
  652  *  Turns the SW defined LED off. This is a function pointer entry point
  653  *  called by drivers.
  654  **/
  655 s32 e1000_led_off(struct e1000_hw *hw)
  656 {
  657         if (hw->func.led_off)
  658                 return hw->func.led_off(hw);
  659 
  660         return E1000_SUCCESS;
  661 }
  662 
  663 /**
  664  *  e1000_reset_adaptive - Reset adaptive IFS
  665  *  @hw: pointer to the HW structure
  666  *
  667  *  Resets the adaptive IFS. Currently no func pointer exists and all
  668  *  implementations are handled in the generic version of this function.
  669  **/
  670 void e1000_reset_adaptive(struct e1000_hw *hw)
  671 {
  672         e1000_reset_adaptive_generic(hw);
  673 }
  674 
  675 /**
  676  *  e1000_update_adaptive - Update adaptive IFS
  677  *  @hw: pointer to the HW structure
  678  *
  679  *  Updates adapter IFS. Currently no func pointer exists and all
  680  *  implementations are handled in the generic version of this function.
  681  **/
  682 void e1000_update_adaptive(struct e1000_hw *hw)
  683 {
  684         e1000_update_adaptive_generic(hw);
  685 }
  686 
  687 /**
  688  *  e1000_disable_pcie_master - Disable PCI-Express master access
  689  *  @hw: pointer to the HW structure
  690  *
  691  *  Disables PCI-Express master access and verifies there are no pending
  692  *  requests. Currently no func pointer exists and all implementations are
  693  *  handled in the generic version of this function.
  694  **/
  695 s32 e1000_disable_pcie_master(struct e1000_hw *hw)
  696 {
  697         return e1000_disable_pcie_master_generic(hw);
  698 }
  699 
  700 /**
  701  *  e1000_config_collision_dist - Configure collision distance
  702  *  @hw: pointer to the HW structure
  703  *
  704  *  Configures the collision distance to the default value and is used
  705  *  during link setup.
  706  **/
  707 void e1000_config_collision_dist(struct e1000_hw *hw)
  708 {
  709         if (hw->func.config_collision_dist)
  710                 hw->func.config_collision_dist(hw);
  711 }
  712 
  713 /**
  714  *  e1000_rar_set - Sets a receive address register
  715  *  @hw: pointer to the HW structure
  716  *  @addr: address to set the RAR to
  717  *  @index: the RAR to set
  718  *
  719  *  Sets a Receive Address Register (RAR) to the specified address.
  720  **/
  721 void e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index)
  722 {
  723         if (hw->func.rar_set)
  724                 hw->func.rar_set(hw, addr, index);
  725 }
  726 
  727 /**
  728  *  e1000_validate_mdi_setting - Ensures valid MDI/MDIX SW state
  729  *  @hw: pointer to the HW structure
  730  *
  731  *  Ensures that the MDI/MDIX SW state is valid.
  732  **/
  733 s32 e1000_validate_mdi_setting(struct e1000_hw *hw)
  734 {
  735         if (hw->func.validate_mdi_setting)
  736                 return hw->func.validate_mdi_setting(hw);
  737 
  738         return E1000_SUCCESS;
  739 }
  740 
  741 /**
  742  *  e1000_mta_set - Sets multicast table bit
  743  *  @hw: pointer to the HW structure
  744  *  @hash_value: Multicast hash value.
  745  *
  746  *  This sets the bit in the multicast table corresponding to the
  747  *  hash value.  This is a function pointer entry point called by drivers.
  748  **/
  749 void e1000_mta_set(struct e1000_hw *hw, u32 hash_value)
  750 {
  751         if (hw->func.mta_set)
  752                 hw->func.mta_set(hw, hash_value);
  753 }
  754 
  755 /**
  756  *  e1000_hash_mc_addr - Determines address location in multicast table
  757  *  @hw: pointer to the HW structure
  758  *  @mc_addr: Multicast address to hash.
  759  *
  760  *  This hashes an address to determine its location in the multicast
  761  *  table. Currently no func pointer exists and all implementations
  762  *  are handled in the generic version of this function.
  763  **/
  764 u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
  765 {
  766         return e1000_hash_mc_addr_generic(hw, mc_addr);
  767 }
  768 
  769 /**
  770  *  e1000_enable_tx_pkt_filtering - Enable packet filtering on TX
  771  *  @hw: pointer to the HW structure
  772  *
  773  *  Enables packet filtering on transmit packets if manageability is enabled
  774  *  and host interface is enabled.
  775  *  Currently no func pointer exists and all implementations are handled in the
  776  *  generic version of this function.
  777  **/
  778 bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw)
  779 {
  780         return e1000_enable_tx_pkt_filtering_generic(hw);
  781 }
  782 
  783 /**
  784  *  e1000_mng_host_if_write - Writes to the manageability host interface
  785  *  @hw: pointer to the HW structure
  786  *  @buffer: pointer to the host interface buffer
  787  *  @length: size of the buffer
  788  *  @offset: location in the buffer to write to
  789  *  @sum: sum of the data (not checksum)
  790  *
  791  *  This function writes the buffer content at the offset given on the host if.
  792  *  It also does alignment considerations to do the writes in most efficient
  793  *  way.  Also fills up the sum of the buffer in *buffer parameter.
  794  **/
  795 s32 e1000_mng_host_if_write(struct e1000_hw * hw, u8 *buffer, u16 length,
  796                             u16 offset, u8 *sum)
  797 {
  798         if (hw->func.mng_host_if_write)
  799                 return hw->func.mng_host_if_write(hw, buffer, length, offset,
  800                                                   sum);
  801 
  802         return E1000_NOT_IMPLEMENTED;
  803 }
  804 
  805 /**
  806  *  e1000_mng_write_cmd_header - Writes manageability command header
  807  *  @hw: pointer to the HW structure
  808  *  @hdr: pointer to the host interface command header
  809  *
  810  *  Writes the command header after does the checksum calculation.
  811  **/
  812 s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
  813                                struct e1000_host_mng_command_header *hdr)
  814 {
  815         if (hw->func.mng_write_cmd_header)
  816                 return hw->func.mng_write_cmd_header(hw, hdr);
  817 
  818         return E1000_NOT_IMPLEMENTED;
  819 }
  820 
  821 /**
  822  *  e1000_mng_enable_host_if - Checks host interface is enabled
  823  *  @hw: pointer to the HW structure
  824  *
  825  *  Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND
  826  *
  827  *  This function checks whether the HOST IF is enabled for command operaton
  828  *  and also checks whether the previous command is completed.  It busy waits
  829  *  in case of previous command is not completed.
  830  **/
  831 s32 e1000_mng_enable_host_if(struct e1000_hw * hw)
  832 {
  833         if (hw->func.mng_enable_host_if)
  834                 return hw->func.mng_enable_host_if(hw);
  835 
  836         return E1000_NOT_IMPLEMENTED;
  837 }
  838 
  839 /**
  840  *  e1000_wait_autoneg - Waits for autonegotiation completion
  841  *  @hw: pointer to the HW structure
  842  *
  843  *  Waits for autoneg to complete. Currently no func pointer exists and all
  844  *  implementations are handled in the generic version of this function.
  845  **/
  846 s32 e1000_wait_autoneg(struct e1000_hw *hw)
  847 {
  848         if (hw->func.wait_autoneg)
  849                 return hw->func.wait_autoneg(hw);
  850 
  851         return E1000_SUCCESS;
  852 }
  853 
  854 /**
  855  *  e1000_check_reset_block - Verifies PHY can be reset
  856  *  @hw: pointer to the HW structure
  857  *
  858  *  Checks if the PHY is in a state that can be reset or if manageability
  859  *  has it tied up. This is a function pointer entry point called by drivers.
  860  **/
  861 s32 e1000_check_reset_block(struct e1000_hw *hw)
  862 {
  863         if (hw->func.check_reset_block)
  864                 return hw->func.check_reset_block(hw);
  865 
  866         return E1000_SUCCESS;
  867 }
  868 
  869 /**
  870  *  e1000_read_phy_reg - Reads PHY register
  871  *  @hw: pointer to the HW structure
  872  *  @offset: the register to read
  873  *  @data: the buffer to store the 16-bit read.
  874  *
  875  *  Reads the PHY register and returns the value in data.
  876  *  This is a function pointer entry point called by drivers.
  877  **/
  878 s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data)
  879 {
  880         if (hw->func.read_phy_reg)
  881                 return hw->func.read_phy_reg(hw, offset, data);
  882 
  883         return E1000_SUCCESS;
  884 }
  885 
  886 /**
  887  *  e1000_write_phy_reg - Writes PHY register
  888  *  @hw: pointer to the HW structure
  889  *  @offset: the register to write
  890  *  @data: the value to write.
  891  *
  892  *  Writes the PHY register at offset with the value in data.
  893  *  This is a function pointer entry point called by drivers.
  894  **/
  895 s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data)
  896 {
  897         if (hw->func.write_phy_reg)
  898                 return hw->func.write_phy_reg(hw, offset, data);
  899 
  900         return E1000_SUCCESS;
  901 }
  902 
  903 /**
  904  *  e1000_read_kmrn_reg - Reads register using Kumeran interface
  905  *  @hw: pointer to the HW structure
  906  *  @offset: the register to read
  907  *  @data: the location to store the 16-bit value read.
  908  *
  909  *  Reads a register out of the Kumeran interface. Currently no func pointer
  910  *  exists and all implementations are handled in the generic version of
  911  *  this function.
  912  **/
  913 s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data)
  914 {
  915         return e1000_read_kmrn_reg_generic(hw, offset, data);
  916 }
  917 
  918 /**
  919  *  e1000_write_kmrn_reg - Writes register using Kumeran interface
  920  *  @hw: pointer to the HW structure
  921  *  @offset: the register to write
  922  *  @data: the value to write.
  923  *
  924  *  Writes a register to the Kumeran interface. Currently no func pointer
  925  *  exists and all implementations are handled in the generic version of
  926  *  this function.
  927  **/
  928 s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data)
  929 {
  930         return e1000_write_kmrn_reg_generic(hw, offset, data);
  931 }
  932 
  933 /**
  934  *  e1000_get_cable_length - Retrieves cable length estimation
  935  *  @hw: pointer to the HW structure
  936  *
  937  *  This function estimates the cable length and stores them in
  938  *  hw->phy.min_length and hw->phy.max_length. This is a function pointer
  939  *  entry point called by drivers.
  940  **/
  941 s32 e1000_get_cable_length(struct e1000_hw *hw)
  942 {
  943         if (hw->func.get_cable_length)
  944                 return hw->func.get_cable_length(hw);
  945 
  946         return E1000_SUCCESS;
  947 }
  948 
  949 /**
  950  *  e1000_get_phy_info - Retrieves PHY information from registers
  951  *  @hw: pointer to the HW structure
  952  *
  953  *  This function gets some information from various PHY registers and
  954  *  populates hw->phy values with it. This is a function pointer entry
  955  *  point called by drivers.
  956  **/
  957 s32 e1000_get_phy_info(struct e1000_hw *hw)
  958 {
  959         if (hw->func.get_phy_info)
  960                 return hw->func.get_phy_info(hw);
  961 
  962         return E1000_SUCCESS;
  963 }
  964 
  965 /**
  966  *  e1000_phy_hw_reset - Hard PHY reset
  967  *  @hw: pointer to the HW structure
  968  *
  969  *  Performs a hard PHY reset. This is a function pointer entry point called
  970  *  by drivers.
  971  **/
  972 s32 e1000_phy_hw_reset(struct e1000_hw *hw)
  973 {
  974         if (hw->func.reset_phy)
  975                 return hw->func.reset_phy(hw);
  976 
  977         return E1000_SUCCESS;
  978 }
  979 
  980 /**
  981  *  e1000_phy_commit - Soft PHY reset
  982  *  @hw: pointer to the HW structure
  983  *
  984  *  Performs a soft PHY reset on those that apply. This is a function pointer
  985  *  entry point called by drivers.
  986  **/
  987 s32 e1000_phy_commit(struct e1000_hw *hw)
  988 {
  989         if (hw->func.commit_phy)
  990                 return hw->func.commit_phy(hw);
  991 
  992         return E1000_SUCCESS;
  993 }
  994 
  995 /**
  996  *  e1000_set_d3_lplu_state - Sets low power link up state for D0
  997  *  @hw: pointer to the HW structure
  998  *  @active: boolean used to enable/disable lplu
  999  *
 1000  *  Success returns 0, Failure returns 1
 1001  *
 1002  *  The low power link up (lplu) state is set to the power management level D0
 1003  *  and SmartSpeed is disabled when active is true, else clear lplu for D0
 1004  *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
 1005  *  is used during Dx states where the power conservation is most important.
 1006  *  During driver activity, SmartSpeed should be enabled so performance is
 1007  *  maintained.  This is a function pointer entry point called by drivers.
 1008  **/
 1009 s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active)
 1010 {
 1011         if (hw->func.set_d0_lplu_state)
 1012                 return hw->func.set_d0_lplu_state(hw, active);
 1013 
 1014         return E1000_SUCCESS;
 1015 }
 1016 
 1017 /**
 1018  *  e1000_set_d3_lplu_state - Sets low power link up state for D3
 1019  *  @hw: pointer to the HW structure
 1020  *  @active: boolean used to enable/disable lplu
 1021  *
 1022  *  Success returns 0, Failure returns 1
 1023  *
 1024  *  The low power link up (lplu) state is set to the power management level D3
 1025  *  and SmartSpeed is disabled when active is true, else clear lplu for D3
 1026  *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU
 1027  *  is used during Dx states where the power conservation is most important.
 1028  *  During driver activity, SmartSpeed should be enabled so performance is
 1029  *  maintained.  This is a function pointer entry point called by drivers.
 1030  **/
 1031 s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)
 1032 {
 1033         if (hw->func.set_d3_lplu_state)
 1034                 return hw->func.set_d3_lplu_state(hw, active);
 1035 
 1036         return E1000_SUCCESS;
 1037 }
 1038 
 1039 /**
 1040  *  e1000_read_mac_addr - Reads MAC address
 1041  *  @hw: pointer to the HW structure
 1042  *
 1043  *  Reads the MAC address out of the adapter and stores it in the HW structure.
 1044  *  Currently no func pointer exists and all implementations are handled in the
 1045  *  generic version of this function.
 1046  **/
 1047 s32 e1000_read_mac_addr(struct e1000_hw *hw)
 1048 {
 1049         if (hw->func.read_mac_addr)
 1050                 return hw->func.read_mac_addr(hw);
 1051 
 1052         return e1000_read_mac_addr_generic(hw);
 1053 }
 1054 
 1055 /**
 1056  *  e1000_read_part_num - Read device part number
 1057  *  @hw: pointer to the HW structure
 1058  *  @part_num: pointer to device part number
 1059  *
 1060  *  Reads the product board assembly (PBA) number from the EEPROM and stores
 1061  *  the value in part_num.
 1062  *  Currently no func pointer exists and all implementations are handled in the
 1063  *  generic version of this function.
 1064  **/
 1065 s32 e1000_read_part_num(struct e1000_hw *hw, u32 *part_num)
 1066 {
 1067         return e1000_read_part_num_generic(hw, part_num);
 1068 }
 1069 
 1070 /**
 1071  *  e1000_validate_nvm_checksum - Verifies NVM (EEPROM) checksum
 1072  *  @hw: pointer to the HW structure
 1073  *
 1074  *  Validates the NVM checksum is correct. This is a function pointer entry
 1075  *  point called by drivers.
 1076  **/
 1077 s32 e1000_validate_nvm_checksum(struct e1000_hw *hw)
 1078 {
 1079         if (hw->func.validate_nvm)
 1080                 return hw->func.validate_nvm(hw);
 1081 
 1082         return -E1000_ERR_CONFIG;
 1083 }
 1084 
 1085 /**
 1086  *  e1000_update_nvm_checksum - Updates NVM (EEPROM) checksum
 1087  *  @hw: pointer to the HW structure
 1088  *
 1089  *  Updates the NVM checksum. Currently no func pointer exists and all
 1090  *  implementations are handled in the generic version of this function.
 1091  **/
 1092 s32 e1000_update_nvm_checksum(struct e1000_hw *hw)
 1093 {
 1094         if (hw->func.update_nvm)
 1095                 return hw->func.update_nvm(hw);
 1096 
 1097         return -E1000_ERR_CONFIG;
 1098 }
 1099 
 1100 /**
 1101  *  e1000_reload_nvm - Reloads EEPROM
 1102  *  @hw: pointer to the HW structure
 1103  *
 1104  *  Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the
 1105  *  extended control register.
 1106  **/
 1107 void e1000_reload_nvm(struct e1000_hw *hw)
 1108 {
 1109         if (hw->func.reload_nvm)
 1110                 hw->func.reload_nvm(hw);
 1111 }
 1112 
 1113 /**
 1114  *  e1000_read_nvm - Reads NVM (EEPROM)
 1115  *  @hw: pointer to the HW structure
 1116  *  @offset: the word offset to read
 1117  *  @words: number of 16-bit words to read
 1118  *  @data: pointer to the properly sized buffer for the data.
 1119  *
 1120  *  Reads 16-bit chunks of data from the NVM (EEPROM). This is a function
 1121  *  pointer entry point called by drivers.
 1122  **/
 1123 s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 1124 {
 1125         if (hw->func.read_nvm)
 1126                 return hw->func.read_nvm(hw, offset, words, data);
 1127 
 1128         return -E1000_ERR_CONFIG;
 1129 }
 1130 
 1131 /**
 1132  *  e1000_write_nvm - Writes to NVM (EEPROM)
 1133  *  @hw: pointer to the HW structure
 1134  *  @offset: the word offset to read
 1135  *  @words: number of 16-bit words to write
 1136  *  @data: pointer to the properly sized buffer for the data.
 1137  *
 1138  *  Writes 16-bit chunks of data to the NVM (EEPROM). This is a function
 1139  *  pointer entry point called by drivers.
 1140  **/
 1141 s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)
 1142 {
 1143         if (hw->func.write_nvm)
 1144                 return hw->func.write_nvm(hw, offset, words, data);
 1145 
 1146         return E1000_SUCCESS;
 1147 }
 1148 
 1149 /**
 1150  *  e1000_write_8bit_ctrl_reg - Writes 8bit Control register
 1151  *  @hw: pointer to the HW structure
 1152  *  @reg: 32bit register offset
 1153  *  @offset: the register to write
 1154  *  @data: the value to write.
 1155  *
 1156  *  Writes the PHY register at offset with the value in data.
 1157  *  This is a function pointer entry point called by drivers.
 1158  **/
 1159 s32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset, u8 data)
 1160 {
 1161         return e1000_write_8bit_ctrl_reg_generic(hw, reg, offset, data);
 1162 }

Cache object: 796f6c7de82cad8683d9d803c85bd468


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.