e1000_api.h revision 173788
117658Sjulian/******************************************************************************* 217658Sjulian 317658Sjulian Copyright (c) 2001-2007, Intel Corporation 417658Sjulian All rights reserved. 517658Sjulian 617658Sjulian Redistribution and use in source and binary forms, with or without 717658Sjulian modification, are permitted provided that the following conditions are met: 817658Sjulian 917658Sjulian 1. Redistributions of source code must retain the above copyright notice, 1017658Sjulian this list of conditions and the following disclaimer. 1117658Sjulian 1217658Sjulian 2. Redistributions in binary form must reproduce the above copyright 1317658Sjulian notice, this list of conditions and the following disclaimer in the 1417658Sjulian documentation and/or other materials provided with the distribution. 1517658Sjulian 1617658Sjulian 3. Neither the name of the Intel Corporation nor the names of its 1717658Sjulian contributors may be used to endorse or promote products derived from 1817658Sjulian this software without specific prior written permission. 1917658Sjulian 2017658Sjulian THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 2117658Sjulian AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2217658Sjulian IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2317658Sjulian ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 2417658Sjulian LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 2517658Sjulian CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 2617658Sjulian SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 2717658Sjulian INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 2817658Sjulian CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 2917658Sjulian ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3017658Sjulian POSSIBILITY OF SUCH DAMAGE. 3117658Sjulian 3217658Sjulian*******************************************************************************/ 3317658Sjulian/* $FreeBSD: head/sys/dev/em/e1000_api.h 173788 2007-11-20 21:41:22Z jfv $ */ 3417658Sjulian 3517658Sjulian 3617658Sjulian#ifndef _E1000_API_H_ 37116182Sobrien#define _E1000_API_H_ 38116182Sobrien 39116182Sobrien#include "e1000_hw.h" 40174921Srwatson 41131927Smarcels32 e1000_set_mac_type(struct e1000_hw *hw); 4228976Sbdes32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device); 4328976Sbdes32 e1000_init_mac_params(struct e1000_hw *hw); 44134649Sscottls32 e1000_init_nvm_params(struct e1000_hw *hw); 4517658Sjulians32 e1000_init_phy_params(struct e1000_hw *hw); 4617658Sjulianvoid e1000_remove_device(struct e1000_hw *hw); 4717658Sjulians32 e1000_get_bus_info(struct e1000_hw *hw); 4860041Sphkvoid e1000_clear_vfta(struct e1000_hw *hw); 4931275Sbdevoid e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value); 5078767Sjhbs32 e1000_force_mac_fc(struct e1000_hw *hw); 5178767Sjhbs32 e1000_check_for_link(struct e1000_hw *hw); 5278767Sjhbs32 e1000_reset_hw(struct e1000_hw *hw); 53193066Sjamies32 e1000_init_hw(struct e1000_hw *hw); 54131927Smarcels32 e1000_setup_link(struct e1000_hw *hw); 5517658Sjulians32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, 56183527Speter u16 *duplex); 5755539Sluoqis32 e1000_disable_pcie_master(struct e1000_hw *hw); 5889601Ssobomaxvoid e1000_config_collision_dist(struct e1000_hw *hw); 5921776Sbdevoid e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index); 60164033Srwatsonvoid e1000_mta_set(struct e1000_hw *hw, u32 hash_value); 6178767Sjhbu32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr); 6278767Sjhbvoid e1000_update_mc_addr_list(struct e1000_hw *hw, 6378767Sjhb u8 *mc_addr_list, u32 mc_addr_count, 64137263Speter u32 rar_used_count, u32 rar_count); 65206878Sattilios32 e1000_setup_led(struct e1000_hw *hw); 6617658Sjulians32 e1000_cleanup_led(struct e1000_hw *hw); 6717658Sjulians32 e1000_check_reset_block(struct e1000_hw *hw); 6817658Sjulians32 e1000_blink_led(struct e1000_hw *hw); 69174921Srwatsons32 e1000_led_on(struct e1000_hw *hw); 70174921Srwatsons32 e1000_led_off(struct e1000_hw *hw); 71118990Smarcelvoid e1000_reset_adaptive(struct e1000_hw *hw); 7294169Sphkvoid e1000_update_adaptive(struct e1000_hw *hw); 7391778Sjakes32 e1000_get_cable_length(struct e1000_hw *hw); 7417658Sjulians32 e1000_validate_mdi_setting(struct e1000_hw *hw); 75163606Srwatsons32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data); 76163606Srwatsons32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data); 77157628Spjds32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, 78157628Spjd u32 offset, u8 data); 79157628Spjds32 e1000_get_phy_info(struct e1000_hw *hw); 80157628Spjds32 e1000_phy_hw_reset(struct e1000_hw *hw); 81157628Spjds32 e1000_phy_commit(struct e1000_hw *hw); 82157628Spjdvoid e1000_power_up_phy(struct e1000_hw *hw); 8317658Sjulianvoid e1000_power_down_phy(struct e1000_hw *hw); 8417658Sjulians32 e1000_read_mac_addr(struct e1000_hw *hw); 8517658Sjulians32 e1000_read_pba_num(struct e1000_hw *hw, u32 *part_num); 8617658Sjulianvoid e1000_reload_nvm(struct e1000_hw *hw); 8717658Sjulians32 e1000_update_nvm_checksum(struct e1000_hw *hw); 8817658Sjulians32 e1000_validate_nvm_checksum(struct e1000_hw *hw); 8917658Sjulians32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); 9017658Sjulians32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data); 9117658Sjulians32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data); 9217658Sjulians32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, 9317658Sjulian u16 *data); 9417658Sjulians32 e1000_wait_autoneg(struct e1000_hw *hw); 95131927Smarcels32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active); 96131927Smarcels32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active); 9742135Smsmithbool e1000_check_mng_mode(struct e1000_hw *hw); 9817658Sjulianbool e1000_enable_mng_pass_thru(struct e1000_hw *hw); 9942135Smsmithbool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw); 10017658Sjulians32 e1000_mng_enable_host_if(struct e1000_hw *hw); 101213322Savgs32 e1000_mng_host_if_write(struct e1000_hw *hw, 10246381Sbillf u8 *buffer, u16 length, u16 offset, u8 *sum); 103213322Savgs32 e1000_mng_write_cmd_header(struct e1000_hw *hw, 104103647Sjhb struct e1000_host_mng_command_header *hdr); 105131927Smarcels32 e1000_mng_write_dhcp_info(struct e1000_hw * hw, 106213322Savg u8 *buffer, u16 length); 107103647Sjhbvoid e1000_tbi_adjust_stats_82543(struct e1000_hw *hw, 108213322Savg struct e1000_hw_stats *stats, 10917658Sjulian u32 frame_len, u8 *mac_addr, 110213322Savg u32 max_frame_size); 111103647Sjhbvoid e1000_set_tbi_compatibility_82543(struct e1000_hw *hw, 112213322Savg bool state); 113131927Smarcelbool e1000_tbi_sbp_enabled_82543(struct e1000_hw *hw); 11417658Sjulian#ifndef NO_82542_SUPPORT 115213322Savgu32 e1000_translate_register_82542(u32 reg); 116213322Savg#endif 11785202Spetervoid e1000_init_script_state_82541(struct e1000_hw *hw, bool state); 118213322Savgbool e1000_get_laa_state_82571(struct e1000_hw *hw); 11985202Spetervoid e1000_set_laa_state_82571(struct e1000_hw *hw, bool state); 12043436Smsmithvoid e1000_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, 12143436Smsmith bool state); 12217658Sjulianvoid e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw); 12317658Sjulianvoid e1000_gig_downshift_workaround_ich8lan(struct e1000_hw *hw); 12417658Sjulian 12517658Sjulian 12617658Sjulian/* 12717658Sjulian * TBI_ACCEPT macro definition: 12893496Sphk * 129155383Sjeff * This macro requires: 13093496Sphk * adapter = a pointer to struct e1000_hw 13167093Sps * status = the 8 bit status field of the Rx descriptor with EOP set 132131927Smarcel * error = the 8 bit error field of the Rx descriptor with EOP set 133131927Smarcel * length = the sum of all the length fields of the Rx descriptors that 134131927Smarcel * make up the current frame 135131927Smarcel * last_byte = the last byte of the frame DMAed by the hardware 13665395Speter * max_frame_length = the maximum frame length we want to accept. 13765395Speter * min_frame_length = the minimum frame length we want to accept. 13865395Speter * 13965395Speter * This macro is a conditional that should be used in the interrupt 14017658Sjulian * handler's Rx processing routine when RxErrors have been detected. 14150107Smsmith * 142110859Salfred * Typical use: 14350107Smsmith * ... 14450107Smsmith * if (TBI_ACCEPT) { 145110859Salfred * accept_frame = TRUE; 146110859Salfred * e1000_tbi_adjust_stats(adapter, MacAddress); 147214279Sbrucec * frame_length--; 148110859Salfred * } else { 149110859Salfred * accept_frame = FALSE; 150110859Salfred * } 151110859Salfred * ... 152110859Salfred */ 153110859Salfred 15450107Smsmith/* The carrier extension symbol, as received by the NIC. */ 15548868Sphk#define CARRIER_EXTENSION 0x0F 156177253Srwatson 15750107Smsmith#define TBI_ACCEPT(a, status, errors, length, last_byte, min_frame_size, max_frame_size) \ 15817658Sjulian (e1000_tbi_sbp_enabled_82543(a) && \ 159167211Srwatson (((errors) & E1000_RXD_ERR_FRAME_ERR_MASK) == E1000_RXD_ERR_CE) && \ 16017658Sjulian ((last_byte) == CARRIER_EXTENSION) && \ 16182749Sdillon (((status) & E1000_RXD_STAT_VP) ? \ 16217658Sjulian (((length) > (min_frame_size - VLAN_TAG_SIZE)) && \ 16383366Sjulian ((length) <= (max_frame_size + 1))) : \ 16417658Sjulian (((length) > min_frame_size) && \ 16517658Sjulian ((length) <= (max_frame_size + VLAN_TAG_SIZE + 1))))) 16617658Sjulian 167106024Srwatson#endif 168106024Srwatson