1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2020 Intel Corporation
6 #include "ixgbe_hv_vf.h"
7 #include "ixgbe_osdep.h"
10 * Hyper-V variant - just a stub.
12 * @mc_addr_list: unused
13 * @mc_addr_count: unused
17 static s32 ixgbevf_hv_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list,
18 u32 mc_addr_count, ixgbe_mc_addr_itr next,
21 UNREFERENCED_5PARAMETER(hw, mc_addr_list, mc_addr_count, next, clear);
23 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
27 * Hyper-V variant - just a stub.
31 static s32 ixgbevf_hv_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode)
33 UNREFERENCED_2PARAMETER(hw, xcast_mode);
35 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
39 * Hyper-V variant - just a stub.
44 * @vlvf_bypass: unused
46 static s32 ixgbevf_hv_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
47 bool vlan_on, bool vlvf_bypass)
49 UNREFERENCED_5PARAMETER(hw, vlan, vind, vlan_on, vlvf_bypass);
51 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
54 static s32 ixgbevf_hv_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr)
56 UNREFERENCED_3PARAMETER(hw, index, addr);
58 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
62 * Hyper-V variant - just a stub.
64 static s32 ixgbevf_hv_reset_hw_vf(struct ixgbe_hw *hw)
66 UNREFERENCED_PARAMETER(hw);
68 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
72 * Hyper-V variant - just a stub.
74 static s32 ixgbevf_hv_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vlan, u32 vind)
76 UNREFERENCED_5PARAMETER(hw, index, addr, vlan, vind);
78 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
82 * Hyper-V variant; there is no mailbox communication.
83 * @hw: pointer to hardware structure
84 * @speed: pointer to link speed
85 * @link_up: true is link is up, false otherwise
86 * @autoneg_wait_to_complete: unused
89 static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw,
90 ixgbe_link_speed *speed,
92 bool autoneg_wait_to_complete)
94 struct ixgbe_mbx_info *mbx = &hw->mbx;
95 struct ixgbe_mac_info *mac = &hw->mac;
97 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
99 /* If we were hit with a reset drop the link */
100 if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
101 mac->get_link_status = true;
103 if (!mac->get_link_status)
106 /* if link status is down no point in checking to see if pf is up */
107 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
108 if (!(links_reg & IXGBE_LINKS_UP))
111 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
112 * before the link status is correct
114 if (mac->type == ixgbe_mac_82599_vf) {
117 for (i = 0; i < 5; i++) {
119 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
121 if (!(links_reg & IXGBE_LINKS_UP))
126 switch (links_reg & IXGBE_LINKS_SPEED_82599) {
127 case IXGBE_LINKS_SPEED_10G_82599:
128 *speed = IXGBE_LINK_SPEED_10GB_FULL;
129 if (hw->mac.type >= ixgbe_mac_X550) {
130 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
131 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
134 case IXGBE_LINKS_SPEED_1G_82599:
135 *speed = IXGBE_LINK_SPEED_1GB_FULL;
137 case IXGBE_LINKS_SPEED_100_82599:
138 *speed = IXGBE_LINK_SPEED_100_FULL;
139 if (hw->mac.type == ixgbe_mac_X550) {
140 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
141 *speed = IXGBE_LINK_SPEED_5GB_FULL;
144 case IXGBE_LINKS_SPEED_10_X550EM_A:
145 *speed = IXGBE_LINK_SPEED_UNKNOWN;
146 /* Reserved for pre-x550 devices */
147 if (hw->mac.type >= ixgbe_mac_X550)
148 *speed = IXGBE_LINK_SPEED_10_FULL;
151 *speed = IXGBE_LINK_SPEED_UNKNOWN;
154 /* if we passed all the tests above then the link is up and we no
155 * longer need to check for link
157 mac->get_link_status = false;
160 *link_up = !mac->get_link_status;
161 return IXGBE_SUCCESS;
165 * ixgbevf_hv_set_rlpml_vf - Set the maximum receive packet length
166 * @hw: pointer to the HW structure
167 * @max_size: value to assign to max frame size
170 static s32 ixgbevf_hv_set_rlpml_vf(struct ixgbe_hw *hw, u16 max_size)
174 /* If we are on Hyper-V, we implement this functionality
177 reg = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(0));
179 reg |= ((max_size + 4) | IXGBE_RXDCTL_RLPML_EN);
180 IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(0), reg);
182 return IXGBE_SUCCESS;
186 * ixgbevf_hv_negotiate_api_version_vf - Negotiate supported API version
187 * @hw: pointer to the HW structure
188 * @api: integer containing requested API version
189 * Hyper-V version - only ixgbe_mbox_api_10 supported.
191 static int ixgbevf_hv_negotiate_api_version_vf(struct ixgbe_hw *hw, int api)
193 UNREFERENCED_1PARAMETER(hw);
195 /* Hyper-V only supports api version ixgbe_mbox_api_10 */
196 if (api != ixgbe_mbox_api_10)
197 return IXGBE_ERR_INVALID_ARGUMENT;
199 return IXGBE_SUCCESS;
203 * ixgbevf_hv_init_ops_vf - Initialize the pointers for vf
204 * @hw: pointer to hardware structure
206 * This will assign function pointers, adapter-specific functions can
207 * override the assignment of generic function pointers by assigning
208 * their own adapter-specific function pointers.
209 * Does not touch the hardware.
211 s32 ixgbevf_hv_init_ops_vf(struct ixgbe_hw *hw)
213 /* Set defaults for VF then override applicable Hyper-V
216 ixgbe_init_ops_vf(hw);
218 hw->mac.ops.reset_hw = ixgbevf_hv_reset_hw_vf;
219 hw->mac.ops.check_link = ixgbevf_hv_check_mac_link_vf;
220 hw->mac.ops.negotiate_api_version = ixgbevf_hv_negotiate_api_version_vf;
221 hw->mac.ops.set_rar = ixgbevf_hv_set_rar_vf;
222 hw->mac.ops.update_mc_addr_list = ixgbevf_hv_update_mc_addr_list_vf;
223 hw->mac.ops.update_xcast_mode = ixgbevf_hv_update_xcast_mode;
224 hw->mac.ops.set_uc_addr = ixgbevf_hv_set_uc_addr_vf;
225 hw->mac.ops.set_vfta = ixgbevf_hv_set_vfta_vf;
226 hw->mac.ops.set_rlpml = ixgbevf_hv_set_rlpml_vf;
228 return IXGBE_SUCCESS;