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 static s32 ixgbevf_hv_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list,
41 u32 mc_addr_count, ixgbe_mc_addr_itr next,
44 UNREFERENCED_5PARAMETER(hw, mc_addr_list, mc_addr_count, next, clear);
46 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
50 * Hyper-V variant - just a stub.
52 static s32 ixgbevf_hv_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode)
54 UNREFERENCED_2PARAMETER(hw, xcast_mode);
56 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
60 * Hyper-V variant - just a stub.
62 static s32 ixgbevf_hv_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
63 bool vlan_on, bool vlvf_bypass)
65 UNREFERENCED_5PARAMETER(hw, vlan, vind, vlan_on, vlvf_bypass);
67 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
70 static s32 ixgbevf_hv_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr)
72 UNREFERENCED_3PARAMETER(hw, index, addr);
74 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
78 * Hyper-V variant - just a stub.
80 static s32 ixgbevf_hv_reset_hw_vf(struct ixgbe_hw *hw)
82 UNREFERENCED_PARAMETER(hw);
84 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
88 * Hyper-V variant - just a stub.
90 static s32 ixgbevf_hv_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vlan, u32 vind)
92 UNREFERENCED_5PARAMETER(hw, index, addr, vlan, vind);
94 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
98 * Hyper-V variant; there is no mailbox communication.
100 static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw,
101 ixgbe_link_speed *speed,
103 bool autoneg_wait_to_complete)
105 struct ixgbe_mbx_info *mbx = &hw->mbx;
106 struct ixgbe_mac_info *mac = &hw->mac;
108 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
110 /* If we were hit with a reset drop the link */
111 if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
112 mac->get_link_status = true;
114 if (!mac->get_link_status)
117 /* if link status is down no point in checking to see if pf is up */
118 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
119 if (!(links_reg & IXGBE_LINKS_UP))
122 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
123 * before the link status is correct
125 if (mac->type == ixgbe_mac_82599_vf) {
128 for (i = 0; i < 5; i++) {
130 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
132 if (!(links_reg & IXGBE_LINKS_UP))
137 switch (links_reg & IXGBE_LINKS_SPEED_82599) {
138 case IXGBE_LINKS_SPEED_10G_82599:
139 *speed = IXGBE_LINK_SPEED_10GB_FULL;
140 if (hw->mac.type >= ixgbe_mac_X550) {
141 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
142 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
145 case IXGBE_LINKS_SPEED_1G_82599:
146 *speed = IXGBE_LINK_SPEED_1GB_FULL;
148 case IXGBE_LINKS_SPEED_100_82599:
149 *speed = IXGBE_LINK_SPEED_100_FULL;
150 if (hw->mac.type == ixgbe_mac_X550) {
151 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
152 *speed = IXGBE_LINK_SPEED_5GB_FULL;
155 case IXGBE_LINKS_SPEED_10_X550EM_A:
156 *speed = IXGBE_LINK_SPEED_UNKNOWN;
157 /* Reserved for pre-x550 devices */
158 if (hw->mac.type >= ixgbe_mac_X550)
159 *speed = IXGBE_LINK_SPEED_10_FULL;
162 *speed = IXGBE_LINK_SPEED_UNKNOWN;
165 /* if we passed all the tests above then the link is up and we no
166 * longer need to check for link
168 mac->get_link_status = false;
171 *link_up = !mac->get_link_status;
172 return IXGBE_SUCCESS;
176 * ixgbevf_hv_set_rlpml_vf - Set the maximum receive packet length
177 * @hw: pointer to the HW structure
178 * @max_size: value to assign to max frame size
181 static s32 ixgbevf_hv_set_rlpml_vf(struct ixgbe_hw *hw, u16 max_size)
185 /* If we are on Hyper-V, we implement this functionality
188 reg = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(0));
190 reg |= ((max_size + 4) | IXGBE_RXDCTL_RLPML_EN);
191 IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(0), reg);
193 return IXGBE_SUCCESS;
197 * ixgbevf_hv_negotiate_api_version_vf - Negotiate supported API version
198 * @hw: pointer to the HW structure
199 * @api: integer containing requested API version
200 * Hyper-V version - only ixgbe_mbox_api_10 supported.
202 static int ixgbevf_hv_negotiate_api_version_vf(struct ixgbe_hw *hw, int api)
204 UNREFERENCED_1PARAMETER(hw);
206 /* Hyper-V only supports api version ixgbe_mbox_api_10 */
207 if (api != ixgbe_mbox_api_10)
208 return IXGBE_ERR_INVALID_ARGUMENT;
210 return IXGBE_SUCCESS;
214 * ixgbevf_hv_init_ops_vf - Initialize the pointers for vf
215 * @hw: pointer to hardware structure
217 * This will assign function pointers, adapter-specific functions can
218 * override the assignment of generic function pointers by assigning
219 * their own adapter-specific function pointers.
220 * Does not touch the hardware.
222 s32 ixgbevf_hv_init_ops_vf(struct ixgbe_hw *hw)
224 /* Set defaults for VF then override applicable Hyper-V
227 ixgbe_init_ops_vf(hw);
229 hw->mac.ops.reset_hw = ixgbevf_hv_reset_hw_vf;
230 hw->mac.ops.check_link = ixgbevf_hv_check_mac_link_vf;
231 hw->mac.ops.negotiate_api_version = ixgbevf_hv_negotiate_api_version_vf;
232 hw->mac.ops.set_rar = ixgbevf_hv_set_rar_vf;
233 hw->mac.ops.update_mc_addr_list = ixgbevf_hv_update_mc_addr_list_vf;
234 hw->mac.ops.update_xcast_mode = ixgbevf_hv_update_xcast_mode;
235 hw->mac.ops.set_uc_addr = ixgbevf_hv_set_uc_addr_vf;
236 hw->mac.ops.set_vfta = ixgbevf_hv_set_vfta_vf;
237 hw->mac.ops.set_rlpml = ixgbevf_hv_set_rlpml_vf;
239 return IXGBE_SUCCESS;