xref: /freebsd/sys/dev/e1000/e1000_api.h (revision 71625ec9ad2a9bc8c09784fbd23b759830e0ee5f)
18cfa0ad2SJack F Vogel /******************************************************************************
27282444bSPedro F. Giffuni   SPDX-License-Identifier: BSD-3-Clause
38cfa0ad2SJack F Vogel 
4702cac6cSKevin Bowling   Copyright (c) 2001-2020, Intel Corporation
58cfa0ad2SJack F Vogel   All rights reserved.
68cfa0ad2SJack F Vogel 
78cfa0ad2SJack F Vogel   Redistribution and use in source and binary forms, with or without
88cfa0ad2SJack F Vogel   modification, are permitted provided that the following conditions are met:
98cfa0ad2SJack F Vogel 
108cfa0ad2SJack F Vogel    1. Redistributions of source code must retain the above copyright notice,
118cfa0ad2SJack F Vogel       this list of conditions and the following disclaimer.
128cfa0ad2SJack F Vogel 
138cfa0ad2SJack F Vogel    2. Redistributions in binary form must reproduce the above copyright
148cfa0ad2SJack F Vogel       notice, this list of conditions and the following disclaimer in the
158cfa0ad2SJack F Vogel       documentation and/or other materials provided with the distribution.
168cfa0ad2SJack F Vogel 
178cfa0ad2SJack F Vogel    3. Neither the name of the Intel Corporation nor the names of its
188cfa0ad2SJack F Vogel       contributors may be used to endorse or promote products derived from
198cfa0ad2SJack F Vogel       this software without specific prior written permission.
208cfa0ad2SJack F Vogel 
218cfa0ad2SJack F Vogel   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
228cfa0ad2SJack F Vogel   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
238cfa0ad2SJack F Vogel   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
248cfa0ad2SJack F Vogel   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
258cfa0ad2SJack F Vogel   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
268cfa0ad2SJack F Vogel   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
278cfa0ad2SJack F Vogel   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
288cfa0ad2SJack F Vogel   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
298cfa0ad2SJack F Vogel   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
308cfa0ad2SJack F Vogel   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
318cfa0ad2SJack F Vogel   POSSIBILITY OF SUCH DAMAGE.
328cfa0ad2SJack F Vogel 
338cfa0ad2SJack F Vogel ******************************************************************************/
348cfa0ad2SJack F Vogel 
358cfa0ad2SJack F Vogel #ifndef _E1000_API_H_
368cfa0ad2SJack F Vogel #define _E1000_API_H_
378cfa0ad2SJack F Vogel 
388cfa0ad2SJack F Vogel #include "e1000_hw.h"
398cfa0ad2SJack F Vogel 
408cfa0ad2SJack F Vogel extern void e1000_init_function_pointers_82542(struct e1000_hw *hw);
418cfa0ad2SJack F Vogel extern void e1000_init_function_pointers_82543(struct e1000_hw *hw);
428cfa0ad2SJack F Vogel extern void e1000_init_function_pointers_82540(struct e1000_hw *hw);
438cfa0ad2SJack F Vogel extern void e1000_init_function_pointers_82571(struct e1000_hw *hw);
448cfa0ad2SJack F Vogel extern void e1000_init_function_pointers_82541(struct e1000_hw *hw);
458cfa0ad2SJack F Vogel extern void e1000_init_function_pointers_80003es2lan(struct e1000_hw *hw);
468cfa0ad2SJack F Vogel extern void e1000_init_function_pointers_ich8lan(struct e1000_hw *hw);
478cfa0ad2SJack F Vogel extern void e1000_init_function_pointers_82575(struct e1000_hw *hw);
488cfa0ad2SJack F Vogel extern void e1000_init_function_pointers_vf(struct e1000_hw *hw);
49a69ed8dfSJack F Vogel extern void e1000_power_up_fiber_serdes_link(struct e1000_hw *hw);
508cfa0ad2SJack F Vogel extern void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw);
51ab5d0362SJack F Vogel extern void e1000_init_function_pointers_i210(struct e1000_hw *hw);
528cfa0ad2SJack F Vogel 
536ab6bfe3SJack F Vogel s32 e1000_set_obff_timer(struct e1000_hw *hw, u32 itr);
548cfa0ad2SJack F Vogel s32 e1000_set_mac_type(struct e1000_hw *hw);
558cfa0ad2SJack F Vogel s32 e1000_setup_init_funcs(struct e1000_hw *hw, bool init_device);
568cfa0ad2SJack F Vogel s32 e1000_init_mac_params(struct e1000_hw *hw);
578cfa0ad2SJack F Vogel s32 e1000_init_nvm_params(struct e1000_hw *hw);
588cfa0ad2SJack F Vogel s32 e1000_init_phy_params(struct e1000_hw *hw);
59b8270585SJack F Vogel s32 e1000_init_mbx_params(struct e1000_hw *hw);
608cfa0ad2SJack F Vogel s32 e1000_get_bus_info(struct e1000_hw *hw);
618cfa0ad2SJack F Vogel void e1000_clear_vfta(struct e1000_hw *hw);
628cfa0ad2SJack F Vogel void e1000_write_vfta(struct e1000_hw *hw, u32 offset, u32 value);
638cfa0ad2SJack F Vogel s32 e1000_force_mac_fc(struct e1000_hw *hw);
648cfa0ad2SJack F Vogel s32 e1000_check_for_link(struct e1000_hw *hw);
658cfa0ad2SJack F Vogel s32 e1000_reset_hw(struct e1000_hw *hw);
668cfa0ad2SJack F Vogel s32 e1000_init_hw(struct e1000_hw *hw);
678cfa0ad2SJack F Vogel s32 e1000_setup_link(struct e1000_hw *hw);
684dab5c37SJack F Vogel s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex);
698cfa0ad2SJack F Vogel s32 e1000_disable_pcie_master(struct e1000_hw *hw);
708cfa0ad2SJack F Vogel void e1000_config_collision_dist(struct e1000_hw *hw);
718cc64f1eSJack F Vogel int e1000_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
728cfa0ad2SJack F Vogel u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr);
734dab5c37SJack F Vogel void e1000_update_mc_addr_list(struct e1000_hw *hw, u8 *mc_addr_list,
744dab5c37SJack F Vogel 			       u32 mc_addr_count);
758cfa0ad2SJack F Vogel s32 e1000_setup_led(struct e1000_hw *hw);
768cfa0ad2SJack F Vogel s32 e1000_cleanup_led(struct e1000_hw *hw);
778cfa0ad2SJack F Vogel s32 e1000_check_reset_block(struct e1000_hw *hw);
788cfa0ad2SJack F Vogel s32 e1000_blink_led(struct e1000_hw *hw);
798cfa0ad2SJack F Vogel s32 e1000_led_on(struct e1000_hw *hw);
808cfa0ad2SJack F Vogel s32 e1000_led_off(struct e1000_hw *hw);
81d035aa2dSJack F Vogel s32 e1000_id_led_init(struct e1000_hw *hw);
828cfa0ad2SJack F Vogel void e1000_reset_adaptive(struct e1000_hw *hw);
838cfa0ad2SJack F Vogel void e1000_update_adaptive(struct e1000_hw *hw);
848cfa0ad2SJack F Vogel s32 e1000_get_cable_length(struct e1000_hw *hw);
858cfa0ad2SJack F Vogel s32 e1000_validate_mdi_setting(struct e1000_hw *hw);
868cfa0ad2SJack F Vogel s32 e1000_read_phy_reg(struct e1000_hw *hw, u32 offset, u16 *data);
878cfa0ad2SJack F Vogel s32 e1000_write_phy_reg(struct e1000_hw *hw, u32 offset, u16 data);
884dab5c37SJack F Vogel s32 e1000_write_8bit_ctrl_reg(struct e1000_hw *hw, u32 reg, u32 offset,
894dab5c37SJack F Vogel 			      u8 data);
908cfa0ad2SJack F Vogel s32 e1000_get_phy_info(struct e1000_hw *hw);
918cfa0ad2SJack F Vogel void e1000_release_phy(struct e1000_hw *hw);
928cfa0ad2SJack F Vogel s32 e1000_acquire_phy(struct e1000_hw *hw);
93daf9197cSJack F Vogel s32 e1000_cfg_on_link_up(struct e1000_hw *hw);
948cfa0ad2SJack F Vogel s32 e1000_phy_hw_reset(struct e1000_hw *hw);
958cfa0ad2SJack F Vogel s32 e1000_phy_commit(struct e1000_hw *hw);
968cfa0ad2SJack F Vogel void e1000_power_up_phy(struct e1000_hw *hw);
978cfa0ad2SJack F Vogel void e1000_power_down_phy(struct e1000_hw *hw);
988cfa0ad2SJack F Vogel s32 e1000_read_mac_addr(struct e1000_hw *hw);
99984d1616SKevin Bowling s32 e1000_read_pba_num(struct e1000_hw *hw, u32 *part_num);
1004dab5c37SJack F Vogel s32 e1000_read_pba_string(struct e1000_hw *hw, u8 *pba_num, u32 pba_num_size);
1017d9119bdSJack F Vogel s32 e1000_read_pba_length(struct e1000_hw *hw, u32 *pba_num_size);
1028cfa0ad2SJack F Vogel void e1000_reload_nvm(struct e1000_hw *hw);
1038cfa0ad2SJack F Vogel s32 e1000_update_nvm_checksum(struct e1000_hw *hw);
1048cfa0ad2SJack F Vogel s32 e1000_validate_nvm_checksum(struct e1000_hw *hw);
1058cfa0ad2SJack F Vogel s32 e1000_read_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
1068cfa0ad2SJack F Vogel s32 e1000_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data);
1078cfa0ad2SJack F Vogel s32 e1000_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data);
1084dab5c37SJack F Vogel s32 e1000_write_nvm(struct e1000_hw *hw, u16 offset, u16 words, u16 *data);
1098cfa0ad2SJack F Vogel s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active);
1108cfa0ad2SJack F Vogel s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active);
1118cfa0ad2SJack F Vogel bool e1000_check_mng_mode(struct e1000_hw *hw);
1128cfa0ad2SJack F Vogel bool e1000_enable_tx_pkt_filtering(struct e1000_hw *hw);
1138cfa0ad2SJack F Vogel s32 e1000_mng_enable_host_if(struct e1000_hw *hw);
1144dab5c37SJack F Vogel s32 e1000_mng_host_if_write(struct e1000_hw *hw, u8 *buffer, u16 length,
1154dab5c37SJack F Vogel 			    u16 offset, u8 *sum);
1168cfa0ad2SJack F Vogel s32 e1000_mng_write_cmd_header(struct e1000_hw *hw,
1178cfa0ad2SJack F Vogel 			       struct e1000_host_mng_command_header *hdr);
1184dab5c37SJack F Vogel s32 e1000_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length);
1198cfa0ad2SJack F Vogel u32  e1000_translate_register_82542(u32 reg);
1208cfa0ad2SJack F Vogel 
1214dab5c37SJack F Vogel 
122ab5d0362SJack F Vogel 
1238cfa0ad2SJack F Vogel /*
1248cfa0ad2SJack F Vogel  * TBI_ACCEPT macro definition:
1258cfa0ad2SJack F Vogel  *
1268cfa0ad2SJack F Vogel  * This macro requires:
12748600901SSean Bruno  *      a = a pointer to struct e1000_hw
1288cfa0ad2SJack F Vogel  *      status = the 8 bit status field of the Rx descriptor with EOP set
12948600901SSean Bruno  *      errors = the 8 bit error field of the Rx descriptor with EOP set
1308cfa0ad2SJack F Vogel  *      length = the sum of all the length fields of the Rx descriptors that
1318cfa0ad2SJack F Vogel  *               make up the current frame
1328cfa0ad2SJack F Vogel  *      last_byte = the last byte of the frame DMAed by the hardware
13348600901SSean Bruno  *      min_frame_size = the minimum frame length we want to accept.
13448600901SSean Bruno  *      max_frame_size = the maximum frame length we want to accept.
1358cfa0ad2SJack F Vogel  *
1368cfa0ad2SJack F Vogel  * This macro is a conditional that should be used in the interrupt
1378cfa0ad2SJack F Vogel  * handler's Rx processing routine when RxErrors have been detected.
1388cfa0ad2SJack F Vogel  *
1398cfa0ad2SJack F Vogel  * Typical use:
1408cfa0ad2SJack F Vogel  *  ...
1418cfa0ad2SJack F Vogel  *  if (TBI_ACCEPT) {
142*1bbdc25fSKevin Bowling  *      accept_frame = true;
1438cfa0ad2SJack F Vogel  *      e1000_tbi_adjust_stats(adapter, MacAddress);
1448cfa0ad2SJack F Vogel  *      frame_length--;
1458cfa0ad2SJack F Vogel  *  } else {
146*1bbdc25fSKevin Bowling  *      accept_frame = false;
1478cfa0ad2SJack F Vogel  *  }
1488cfa0ad2SJack F Vogel  *  ...
1498cfa0ad2SJack F Vogel  */
1508cfa0ad2SJack F Vogel 
1518cfa0ad2SJack F Vogel /* The carrier extension symbol, as received by the NIC. */
1528cfa0ad2SJack F Vogel #define CARRIER_EXTENSION   0x0F
1538cfa0ad2SJack F Vogel 
1544dab5c37SJack F Vogel #define TBI_ACCEPT(a, status, errors, length, last_byte, \
1554dab5c37SJack F Vogel 		   min_frame_size, max_frame_size) \
1568cfa0ad2SJack F Vogel 	(e1000_tbi_sbp_enabled_82543(a) && \
1578cfa0ad2SJack F Vogel 	 (((errors) & E1000_RXD_ERR_FRAME_ERR_MASK) == E1000_RXD_ERR_CE) && \
1588cfa0ad2SJack F Vogel 	 ((last_byte) == CARRIER_EXTENSION) && \
1598cfa0ad2SJack F Vogel 	 (((status) & E1000_RXD_STAT_VP) ? \
16048600901SSean Bruno 	  (((length) > ((min_frame_size) - VLAN_TAG_SIZE)) && \
16148600901SSean Bruno 	  ((length) <= ((max_frame_size) + 1))) : \
16248600901SSean Bruno 	  (((length) > (min_frame_size)) && \
16348600901SSean Bruno 	  ((length) <= ((max_frame_size) + VLAN_TAG_SIZE + 1)))))
1648cfa0ad2SJack F Vogel 
1656ab6bfe3SJack F Vogel #define E1000_MAX(a, b) ((a) > (b) ? (a) : (b))
1666ab6bfe3SJack F Vogel #define E1000_DIVIDE_ROUND_UP(a, b)	(((a) + (b) - 1) / (b)) /* ceil(a/b) */
1676ab6bfe3SJack F Vogel #endif /* _E1000_API_H_ */
168