1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2001-2018
6 #include "ixgbe_hv_vf.h"
9 * Hyper-V variant - just a stub.
11 * @mc_addr_list: unused
12 * @mc_addr_count: unused
16 static s32 ixgbevf_hv_update_mc_addr_list_vf(struct ixgbe_hw *hw, u8 *mc_addr_list,
17 u32 mc_addr_count, ixgbe_mc_addr_itr next,
20 UNREFERENCED_5PARAMETER(hw, mc_addr_list, mc_addr_count, next, clear);
22 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
26 * Hyper-V variant - just a stub.
30 static s32 ixgbevf_hv_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode)
32 UNREFERENCED_2PARAMETER(hw, xcast_mode);
34 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
38 * Hyper-V variant - just a stub.
43 * @vlvf_bypass: unused
45 static s32 ixgbevf_hv_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
46 bool vlan_on, bool vlvf_bypass)
48 UNREFERENCED_5PARAMETER(hw, vlan, vind, vlan_on, vlvf_bypass);
50 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
53 static s32 ixgbevf_hv_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr)
55 UNREFERENCED_3PARAMETER(hw, index, addr);
57 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
61 * Hyper-V variant - just a stub.
63 static s32 ixgbevf_hv_reset_hw_vf(struct ixgbe_hw *hw)
65 UNREFERENCED_PARAMETER(hw);
67 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
71 * Hyper-V variant - just a stub.
73 static s32 ixgbevf_hv_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vlan, u32 vind)
75 UNREFERENCED_5PARAMETER(hw, index, addr, vlan, vind);
77 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
81 * Hyper-V variant; there is no mailbox communication.
82 * @hw: pointer to hardware structure
83 * @speed: pointer to link speed
84 * @link_up: true is link is up, false otherwise
85 * @autoneg_wait_to_complete: unused
88 static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw,
89 ixgbe_link_speed *speed,
91 bool autoneg_wait_to_complete)
93 struct ixgbe_mbx_info *mbx = &hw->mbx;
94 struct ixgbe_mac_info *mac = &hw->mac;
96 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
98 /* If we were hit with a reset drop the link */
99 if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
100 mac->get_link_status = true;
102 if (!mac->get_link_status)
105 /* if link status is down no point in checking to see if pf is up */
106 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
107 if (!(links_reg & IXGBE_LINKS_UP))
110 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
111 * before the link status is correct
113 if (mac->type == ixgbe_mac_82599_vf) {
116 for (i = 0; i < 5; i++) {
118 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
120 if (!(links_reg & IXGBE_LINKS_UP))
125 switch (links_reg & IXGBE_LINKS_SPEED_82599) {
126 case IXGBE_LINKS_SPEED_10G_82599:
127 *speed = IXGBE_LINK_SPEED_10GB_FULL;
128 if (hw->mac.type >= ixgbe_mac_X550) {
129 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
130 *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
133 case IXGBE_LINKS_SPEED_1G_82599:
134 *speed = IXGBE_LINK_SPEED_1GB_FULL;
136 case IXGBE_LINKS_SPEED_100_82599:
137 *speed = IXGBE_LINK_SPEED_100_FULL;
138 if (hw->mac.type == ixgbe_mac_X550) {
139 if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
140 *speed = IXGBE_LINK_SPEED_5GB_FULL;
143 case IXGBE_LINKS_SPEED_10_X550EM_A:
144 *speed = IXGBE_LINK_SPEED_UNKNOWN;
145 /* Reserved for pre-x550 devices */
146 if (hw->mac.type >= ixgbe_mac_X550)
147 *speed = IXGBE_LINK_SPEED_10_FULL;
150 *speed = IXGBE_LINK_SPEED_UNKNOWN;
153 /* if we passed all the tests above then the link is up and we no
154 * longer need to check for link
156 mac->get_link_status = false;
159 *link_up = !mac->get_link_status;
160 return IXGBE_SUCCESS;
164 * ixgbevf_hv_set_rlpml_vf - Set the maximum receive packet length
165 * @hw: pointer to the HW structure
166 * @max_size: value to assign to max frame size
169 static s32 ixgbevf_hv_set_rlpml_vf(struct ixgbe_hw *hw, u16 max_size)
173 /* If we are on Hyper-V, we implement this functionality
176 reg = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(0));
178 reg |= ((max_size + 4) | IXGBE_RXDCTL_RLPML_EN);
179 IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(0), reg);
181 return IXGBE_SUCCESS;
185 * ixgbevf_hv_negotiate_api_version_vf - Negotiate supported API version
186 * @hw: pointer to the HW structure
187 * @api: integer containing requested API version
188 * Hyper-V version - only ixgbe_mbox_api_10 supported.
190 static int ixgbevf_hv_negotiate_api_version_vf(struct ixgbe_hw *hw, int api)
192 UNREFERENCED_1PARAMETER(hw);
194 /* Hyper-V only supports api version ixgbe_mbox_api_10 */
195 if (api != ixgbe_mbox_api_10)
196 return IXGBE_ERR_INVALID_ARGUMENT;
198 return IXGBE_SUCCESS;
202 * ixgbevf_hv_init_ops_vf - Initialize the pointers for vf
203 * @hw: pointer to hardware structure
205 * This will assign function pointers, adapter-specific functions can
206 * override the assignment of generic function pointers by assigning
207 * their own adapter-specific function pointers.
208 * Does not touch the hardware.
210 s32 ixgbevf_hv_init_ops_vf(struct ixgbe_hw *hw)
212 /* Set defaults for VF then override applicable Hyper-V
215 ixgbe_init_ops_vf(hw);
217 hw->mac.ops.reset_hw = ixgbevf_hv_reset_hw_vf;
218 hw->mac.ops.check_link = ixgbevf_hv_check_mac_link_vf;
219 hw->mac.ops.negotiate_api_version = ixgbevf_hv_negotiate_api_version_vf;
220 hw->mac.ops.set_rar = ixgbevf_hv_set_rar_vf;
221 hw->mac.ops.update_mc_addr_list = ixgbevf_hv_update_mc_addr_list_vf;
222 hw->mac.ops.update_xcast_mode = ixgbevf_hv_update_xcast_mode;
223 hw->mac.ops.set_uc_addr = ixgbevf_hv_set_uc_addr_vf;
224 hw->mac.ops.set_vfta = ixgbevf_hv_set_vfta_vf;
225 hw->mac.ops.set_rlpml = ixgbevf_hv_set_rlpml_vf;
227 return IXGBE_SUCCESS;