1 /*******************************************************************************
3 Copyright (c) 2001-2015, Intel Corporation
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
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.
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.
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.
32 ***************************************************************************/
35 #include "ixgbe_hv_vf.h"
38 * Hyper-V variant - just a stub.
40 * @mc_addr_list: unused
41 * @mc_addr_count: unused
45 static s32 ixgbevf_hv_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list,
46 u32 mc_addr_count, ixgbe_mc_addr_itr next,
49 UNREFERENCED_5PARAMETER(hw, mc_addr_list, mc_addr_count, next, clear);
51 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
55 * Hyper-V variant - just a stub.
59 static s32 ixgbevf_hv_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode)
61 UNREFERENCED_2PARAMETER(hw, xcast_mode);
63 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
67 * Hyper-V variant - just a stub.
72 * @vlvf_bypass: unused
74 static s32 ixgbevf_hv_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
75 bool vlan_on, bool vlvf_bypass)
77 UNREFERENCED_5PARAMETER(hw, vlan, vind, vlan_on, vlvf_bypass);
79 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
82 static s32 ixgbevf_hv_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr)
84 UNREFERENCED_3PARAMETER(hw, index, addr);
86 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
90 * Hyper-V variant - just a stub.
92 static s32 ixgbevf_hv_reset_hw_vf(struct ixgbe_hw *hw)
94 UNREFERENCED_PARAMETER(hw);
96 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
100 * Hyper-V variant - just a stub.
102 static s32 ixgbevf_hv_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vlan, u32 vind)
104 UNREFERENCED_5PARAMETER(hw, index, addr, vlan, vind);
106 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
110 * Hyper-V variant; there is no mailbox communication.
111 * @hw: pointer to hardware structure
112 * @speed: pointer to link speed
113 * @link_up: true is link is up, false otherwise
114 * @autoneg_wait_to_complete: unused
117 static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw,
118 ixgbe_link_speed *speed,
120 bool autoneg_wait_to_complete)
122 struct ixgbe_mbx_info *mbx = &hw->mbx;
123 struct ixgbe_mac_info *mac = &hw->mac;
125 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
127 /* If we were hit with a reset drop the link */
128 if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
129 mac->get_link_status = true;
131 if (!mac->get_link_status)
134 /* if link status is down no point in checking to see if pf is up */
135 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
136 if (!(links_reg & IXGBE_LINKS_UP))
139 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
140 * before the link status is correct
142 if (mac->type == ixgbe_mac_82599_vf) {
145 for (i = 0; i < 5; i++) {
147 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
149 if (!(links_reg & IXGBE_LINKS_UP))
154 switch (links_reg & IXGBE_LINKS_SPEED_82599) {
155 case IXGBE_LINKS_SPEED_10G_82599:
156 *speed = IXGBE_LINK_SPEED_10GB_FULL;
157 if (hw->mac.type >= ixgbe_mac_X550) {
158 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
159 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
162 case IXGBE_LINKS_SPEED_1G_82599:
163 *speed = IXGBE_LINK_SPEED_1GB_FULL;
165 case IXGBE_LINKS_SPEED_100_82599:
166 *speed = IXGBE_LINK_SPEED_100_FULL;
167 if (hw->mac.type == ixgbe_mac_X550) {
168 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
169 *speed = IXGBE_LINK_SPEED_5GB_FULL;
172 case IXGBE_LINKS_SPEED_10_X550EM_A:
173 *speed = IXGBE_LINK_SPEED_UNKNOWN;
174 /* Reserved for pre-x550 devices */
175 if (hw->mac.type >= ixgbe_mac_X550)
176 *speed = IXGBE_LINK_SPEED_10_FULL;
179 *speed = IXGBE_LINK_SPEED_UNKNOWN;
182 /* if we passed all the tests above then the link is up and we no
183 * longer need to check for link
185 mac->get_link_status = false;
188 *link_up = !mac->get_link_status;
189 return IXGBE_SUCCESS;
193 * ixgbevf_hv_set_rlpml_vf - Set the maximum receive packet length
194 * @hw: pointer to the HW structure
195 * @max_size: value to assign to max frame size
198 static s32 ixgbevf_hv_set_rlpml_vf(struct ixgbe_hw *hw, u16 max_size)
202 /* If we are on Hyper-V, we implement this functionality
205 reg = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(0));
207 reg |= ((max_size + 4) | IXGBE_RXDCTL_RLPML_EN);
208 IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(0), reg);
210 return IXGBE_SUCCESS;
214 * ixgbevf_hv_negotiate_api_version_vf - Negotiate supported API version
215 * @hw: pointer to the HW structure
216 * @api: integer containing requested API version
217 * Hyper-V version - only ixgbe_mbox_api_10 supported.
219 static int ixgbevf_hv_negotiate_api_version_vf(struct ixgbe_hw *hw, int api)
221 UNREFERENCED_1PARAMETER(hw);
223 /* Hyper-V only supports api version ixgbe_mbox_api_10 */
224 if (api != ixgbe_mbox_api_10)
225 return IXGBE_ERR_INVALID_ARGUMENT;
227 return IXGBE_SUCCESS;
231 * ixgbevf_hv_init_ops_vf - Initialize the pointers for vf
232 * @hw: pointer to hardware structure
234 * This will assign function pointers, adapter-specific functions can
235 * override the assignment of generic function pointers by assigning
236 * their own adapter-specific function pointers.
237 * Does not touch the hardware.
239 s32 ixgbevf_hv_init_ops_vf(struct ixgbe_hw *hw)
241 /* Set defaults for VF then override applicable Hyper-V
244 ixgbe_init_ops_vf(hw);
246 hw->mac.ops.reset_hw = ixgbevf_hv_reset_hw_vf;
247 hw->mac.ops.check_link = ixgbevf_hv_check_mac_link_vf;
248 hw->mac.ops.negotiate_api_version = ixgbevf_hv_negotiate_api_version_vf;
249 hw->mac.ops.set_rar = ixgbevf_hv_set_rar_vf;
250 hw->mac.ops.update_mc_addr_list = ixgbevf_hv_update_mc_addr_list_vf;
251 hw->mac.ops.update_xcast_mode = ixgbevf_hv_update_xcast_mode;
252 hw->mac.ops.set_uc_addr = ixgbevf_hv_set_uc_addr_vf;
253 hw->mac.ops.set_vfta = ixgbevf_hv_set_vfta_vf;
254 hw->mac.ops.set_rlpml = ixgbevf_hv_set_rlpml_vf;
256 return IXGBE_SUCCESS;