1179055Sjfv/******************************************************************************
2171384Sjfv
3320897Serj  Copyright (c) 2001-2017, Intel Corporation
4171384Sjfv  All rights reserved.
5320897Serj
6320897Serj  Redistribution and use in source and binary forms, with or without
7171384Sjfv  modification, are permitted provided that the following conditions are met:
8320897Serj
9320897Serj   1. Redistributions of source code must retain the above copyright notice,
10171384Sjfv      this list of conditions and the following disclaimer.
11320897Serj
12320897Serj   2. Redistributions in binary form must reproduce the above copyright
13320897Serj      notice, this list of conditions and the following disclaimer in the
14171384Sjfv      documentation and/or other materials provided with the distribution.
15320897Serj
16320897Serj   3. Neither the name of the Intel Corporation nor the names of its
17320897Serj      contributors may be used to endorse or promote products derived from
18171384Sjfv      this software without specific prior written permission.
19320897Serj
20171384Sjfv  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21320897Serj  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22320897Serj  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23320897Serj  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24320897Serj  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25320897Serj  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26320897Serj  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27320897Serj  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28320897Serj  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29171384Sjfv  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30171384Sjfv  POSSIBILITY OF SUCH DAMAGE.
31171384Sjfv
32179055Sjfv******************************************************************************/
33179055Sjfv/*$FreeBSD: stable/11/sys/dev/ixgbe/ixgbe_common.h 320897 2017-07-11 21:25:07Z erj $*/
34171384Sjfv
35171384Sjfv#ifndef _IXGBE_COMMON_H_
36171384Sjfv#define _IXGBE_COMMON_H_
37171384Sjfv
38171384Sjfv#include "ixgbe_type.h"
39190873Sjfv#define IXGBE_WRITE_REG64(hw, reg, value) \
40190873Sjfv	do { \
41190873Sjfv		IXGBE_WRITE_REG(hw, reg, (u32) value); \
42190873Sjfv		IXGBE_WRITE_REG(hw, reg + 4, (u32) (value >> 32)); \
43190873Sjfv	} while (0)
44280182Sjfv#define IXGBE_REMOVED(a) (0)
45247822Sjfv#if !defined(NO_READ_PBA_RAW) || !defined(NO_WRITE_PBA_RAW)
46247822Sjfvstruct ixgbe_pba {
47247822Sjfv	u16 word[2];
48247822Sjfv	u16 *pba_block;
49247822Sjfv};
50247822Sjfv#endif
51171384Sjfv
52251964Sjfvvoid ixgbe_dcb_get_rtrup2tc_generic(struct ixgbe_hw *hw, u8 *map);
53251964Sjfv
54238149Sjfvu16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw);
55179055Sjfvs32 ixgbe_init_ops_generic(struct ixgbe_hw *hw);
56171384Sjfvs32 ixgbe_init_hw_generic(struct ixgbe_hw *hw);
57171384Sjfvs32 ixgbe_start_hw_generic(struct ixgbe_hw *hw);
58215911Sjfvs32 ixgbe_start_hw_gen2(struct ixgbe_hw *hw);
59171384Sjfvs32 ixgbe_clear_hw_cntrs_generic(struct ixgbe_hw *hw);
60179055Sjfvs32 ixgbe_read_pba_num_generic(struct ixgbe_hw *hw, u32 *pba_num);
61215911Sjfvs32 ixgbe_read_pba_string_generic(struct ixgbe_hw *hw, u8 *pba_num,
62230775Sjfv				  u32 pba_num_size);
63247822Sjfvs32 ixgbe_read_pba_raw(struct ixgbe_hw *hw, u16 *eeprom_buf,
64247822Sjfv		       u32 eeprom_buf_size, u16 max_pba_block_size,
65247822Sjfv		       struct ixgbe_pba *pba);
66247822Sjfvs32 ixgbe_write_pba_raw(struct ixgbe_hw *hw, u16 *eeprom_buf,
67247822Sjfv			u32 eeprom_buf_size, struct ixgbe_pba *pba);
68247822Sjfvs32 ixgbe_get_pba_block_size(struct ixgbe_hw *hw, u16 *eeprom_buf,
69247822Sjfv			     u32 eeprom_buf_size, u16 *pba_block_size);
70171384Sjfvs32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr);
71171384Sjfvs32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw);
72251964Sjfvvoid ixgbe_set_pci_config_data_generic(struct ixgbe_hw *hw, u16 link_status);
73185352Sjfvvoid ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw);
74171384Sjfvs32 ixgbe_stop_adapter_generic(struct ixgbe_hw *hw);
75171384Sjfv
76171384Sjfvs32 ixgbe_led_on_generic(struct ixgbe_hw *hw, u32 index);
77171384Sjfvs32 ixgbe_led_off_generic(struct ixgbe_hw *hw, u32 index);
78320897Serjs32 ixgbe_init_led_link_act_generic(struct ixgbe_hw *hw);
79171384Sjfv
80171384Sjfvs32 ixgbe_init_eeprom_params_generic(struct ixgbe_hw *hw);
81171384Sjfvs32 ixgbe_write_eeprom_generic(struct ixgbe_hw *hw, u16 offset, u16 data);
82230775Sjfvs32 ixgbe_write_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
83230775Sjfv					       u16 words, u16 *data);
84200239Sjfvs32 ixgbe_read_eerd_generic(struct ixgbe_hw *hw, u16 offset, u16 *data);
85230775Sjfvs32 ixgbe_read_eerd_buffer_generic(struct ixgbe_hw *hw, u16 offset,
86230775Sjfv				   u16 words, u16 *data);
87215911Sjfvs32 ixgbe_write_eewr_generic(struct ixgbe_hw *hw, u16 offset, u16 data);
88230775Sjfvs32 ixgbe_write_eewr_buffer_generic(struct ixgbe_hw *hw, u16 offset,
89230775Sjfv				    u16 words, u16 *data);
90171384Sjfvs32 ixgbe_read_eeprom_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
91230775Sjfv				       u16 *data);
92230775Sjfvs32 ixgbe_read_eeprom_buffer_bit_bang_generic(struct ixgbe_hw *hw, u16 offset,
93230775Sjfv					      u16 words, u16 *data);
94280182Sjfvs32 ixgbe_calc_eeprom_checksum_generic(struct ixgbe_hw *hw);
95171384Sjfvs32 ixgbe_validate_eeprom_checksum_generic(struct ixgbe_hw *hw,
96230775Sjfv					   u16 *checksum_val);
97171384Sjfvs32 ixgbe_update_eeprom_checksum_generic(struct ixgbe_hw *hw);
98200239Sjfvs32 ixgbe_poll_eerd_eewr_done(struct ixgbe_hw *hw, u32 ee_reg);
99171384Sjfv
100179055Sjfvs32 ixgbe_set_rar_generic(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vmdq,
101230775Sjfv			  u32 enable_addr);
102181003Sjfvs32 ixgbe_clear_rar_generic(struct ixgbe_hw *hw, u32 index);
103171384Sjfvs32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw);
104171384Sjfvs32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw, u8 *mc_addr_list,
105230775Sjfv				      u32 mc_addr_count,
106230775Sjfv				      ixgbe_mc_addr_itr func, bool clear);
107179055Sjfvs32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw, u8 *addr_list,
108230775Sjfv				      u32 addr_count, ixgbe_mc_addr_itr func);
109171384Sjfvs32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw);
110171384Sjfvs32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw);
111190873Sjfvs32 ixgbe_enable_rx_dma_generic(struct ixgbe_hw *hw, u32 regval);
112230775Sjfvs32 ixgbe_disable_sec_rx_path_generic(struct ixgbe_hw *hw);
113230775Sjfvs32 ixgbe_enable_sec_rx_path_generic(struct ixgbe_hw *hw);
114171384Sjfv
115238149Sjfvs32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw);
116251964Sjfvbool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw);
117238149Sjfvvoid ixgbe_fc_autoneg(struct ixgbe_hw *hw);
118280182Sjfvs32 ixgbe_setup_fc_generic(struct ixgbe_hw *hw);
119185352Sjfv
120171384Sjfvs32 ixgbe_validate_mac_addr(u8 *mac_addr);
121280182Sjfvs32 ixgbe_acquire_swfw_sync(struct ixgbe_hw *hw, u32 mask);
122280182Sjfvvoid ixgbe_release_swfw_sync(struct ixgbe_hw *hw, u32 mask);
123171384Sjfvs32 ixgbe_disable_pcie_master(struct ixgbe_hw *hw);
124171384Sjfv
125280182Sjfvs32 prot_autoc_read_generic(struct ixgbe_hw *hw, bool *, u32 *reg_val);
126280182Sjfvs32 prot_autoc_write_generic(struct ixgbe_hw *hw, u32 reg_val, bool locked);
127280182Sjfv
128190873Sjfvs32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index);
129190873Sjfvs32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index);
130190873Sjfv
131200239Sjfvs32 ixgbe_get_san_mac_addr_generic(struct ixgbe_hw *hw, u8 *san_mac_addr);
132200239Sjfvs32 ixgbe_set_san_mac_addr_generic(struct ixgbe_hw *hw, u8 *san_mac_addr);
133200239Sjfv
134200239Sjfvs32 ixgbe_set_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
135238149Sjfvs32 ixgbe_set_vmdq_san_mac_generic(struct ixgbe_hw *hw, u32 vmdq);
136200239Sjfvs32 ixgbe_clear_vmdq_generic(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
137200239Sjfvs32 ixgbe_insert_mac_addr_generic(struct ixgbe_hw *hw, u8 *addr, u32 vmdq);
138200239Sjfvs32 ixgbe_init_uta_tables_generic(struct ixgbe_hw *hw);
139200239Sjfvs32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan,
140320897Serj			 u32 vind, bool vlan_on, bool vlvf_bypass);
141230775Sjfvs32 ixgbe_set_vlvf_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
142320897Serj			   bool vlan_on, u32 *vfta_delta, u32 vfta,
143320897Serj			   bool vlvf_bypass);
144200239Sjfvs32 ixgbe_clear_vfta_generic(struct ixgbe_hw *hw);
145320897Serjs32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan, bool vlvf_bypass);
146200239Sjfv
147200239Sjfvs32 ixgbe_check_mac_link_generic(struct ixgbe_hw *hw,
148230775Sjfv			       ixgbe_link_speed *speed,
149230775Sjfv			       bool *link_up, bool link_up_wait_to_complete);
150200239Sjfv
151200239Sjfvs32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix,
152230775Sjfv				 u16 *wwpn_prefix);
153200239Sjfv
154215911Sjfvs32 ixgbe_get_fcoe_boot_status_generic(struct ixgbe_hw *hw, u16 *bs);
155320897Serjvoid ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
156215911Sjfvvoid ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
157217593Sjfvs32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps);
158230775Sjfvvoid ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb, u32 headroom,
159230775Sjfv			     int strategy);
160217593Sjfvvoid ixgbe_enable_relaxed_ordering_gen2(struct ixgbe_hw *hw);
161230775Sjfvs32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,
162320897Serj				 u8 build, u8 ver, u16 len, const char *str);
163247822Sjfvu8 ixgbe_calculate_checksum(u8 *buffer, u32 length);
164247822Sjfvs32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
165280182Sjfv				 u32 length, u32 timeout, bool return_data);
166320897Serjs32 ixgbe_hic_unlocked(struct ixgbe_hw *, u32 *buffer, u32 length, u32 timeout);
167320897Serjs32 ixgbe_shutdown_fw_phy(struct ixgbe_hw *);
168320897Serjs32 ixgbe_fw_phy_activity(struct ixgbe_hw *, u16 activity,
169320897Serj			  u32 (*data)[FW_PHY_ACT_DATA_COUNT]);
170230775Sjfvvoid ixgbe_clear_tx_pending(struct ixgbe_hw *hw);
171320897Serjs32 ixgbe_bypass_rw_generic(struct ixgbe_hw *hw, u32 cmd, u32 *status);
172320897Serjbool ixgbe_bypass_valid_rd_generic(u32 in_reg, u32 out_reg);
173320897Serjs32 ixgbe_bypass_set_generic(struct ixgbe_hw *hw, u32 ctrl, u32 event,
174320897Serj			     u32 action);
175320897Serjs32 ixgbe_bypass_rd_eep_generic(struct ixgbe_hw *hw, u32 addr, u8 *value);
176247822Sjfv
177247822Sjfvextern s32 ixgbe_reset_pipeline_82599(struct ixgbe_hw *hw);
178251964Sjfvextern void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw);
179280182Sjfvbool ixgbe_mng_present(struct ixgbe_hw *hw);
180280182Sjfvbool ixgbe_mng_enabled(struct ixgbe_hw *hw);
181247822Sjfv
182280182Sjfvvoid ixgbe_disable_rx_generic(struct ixgbe_hw *hw);
183280182Sjfvvoid ixgbe_enable_rx_generic(struct ixgbe_hw *hw);
184280182Sjfvs32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,
185280182Sjfv					  ixgbe_link_speed speed,
186280182Sjfv					  bool autoneg_wait_to_complete);
187280182Sjfvvoid ixgbe_set_soft_rate_select_speed(struct ixgbe_hw *hw,
188280182Sjfv				      ixgbe_link_speed speed);
189171384Sjfv#endif /* IXGBE_COMMON */
190