Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2001-2020 Intel Corporation
3 : : */
4 : :
5 : : #include "ixgbe_vf.h"
6 : : #include "ixgbe_hv_vf.h"
7 : : #include "ixgbe_osdep.h"
8 : :
9 : : /**
10 : : * Hyper-V variant - just a stub.
11 : : * @hw: unused
12 : : * @mc_addr_list: unused
13 : : * @mc_addr_count: unused
14 : : * @next: unused
15 : : * @clear: unused
16 : : */
17 : 0 : 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,
19 : : bool clear)
20 : : {
21 : : UNREFERENCED_5PARAMETER(hw, mc_addr_list, mc_addr_count, next, clear);
22 : :
23 : 0 : return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
24 : : }
25 : :
26 : : /**
27 : : * Hyper-V variant - just a stub.
28 : : * @hw: unused
29 : : * @xcast_mode: unused
30 : : */
31 : 0 : static s32 ixgbevf_hv_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode)
32 : : {
33 : : UNREFERENCED_2PARAMETER(hw, xcast_mode);
34 : :
35 : 0 : return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
36 : : }
37 : :
38 : : /**
39 : : * Hyper-V variant - just a stub.
40 : : * @hw: unused
41 : : * @vlan: unused
42 : : * @vind: unused
43 : : * @vlan_on: unused
44 : : * @vlvf_bypass: unused
45 : : */
46 : 0 : static s32 ixgbevf_hv_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
47 : : bool vlan_on, bool vlvf_bypass)
48 : : {
49 : : UNREFERENCED_5PARAMETER(hw, vlan, vind, vlan_on, vlvf_bypass);
50 : :
51 : 0 : return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
52 : : }
53 : :
54 : 0 : static s32 ixgbevf_hv_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr)
55 : : {
56 : : UNREFERENCED_3PARAMETER(hw, index, addr);
57 : :
58 : 0 : return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
59 : : }
60 : :
61 : : /**
62 : : * Hyper-V variant - just a stub.
63 : : */
64 : 0 : static s32 ixgbevf_hv_reset_hw_vf(struct ixgbe_hw *hw)
65 : : {
66 : : UNREFERENCED_PARAMETER(hw);
67 : :
68 : 0 : return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
69 : : }
70 : :
71 : : /**
72 : : * Hyper-V variant - just a stub.
73 : : */
74 : 0 : static s32 ixgbevf_hv_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vlan, u32 vind)
75 : : {
76 : : UNREFERENCED_5PARAMETER(hw, index, addr, vlan, vind);
77 : :
78 : 0 : return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
79 : : }
80 : :
81 : : /**
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
87 : : *
88 : : */
89 : 0 : static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw,
90 : : ixgbe_link_speed *speed,
91 : : bool *link_up,
92 : : bool autoneg_wait_to_complete)
93 : : {
94 : : struct ixgbe_mbx_info *mbx = &hw->mbx;
95 : : struct ixgbe_mac_info *mac = &hw->mac;
96 : : u32 links_reg;
97 : : UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
98 : :
99 : : /* If we were hit with a reset drop the link */
100 [ # # # # ]: 0 : if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
101 : 0 : mac->get_link_status = true;
102 : :
103 [ # # ]: 0 : if (!mac->get_link_status)
104 : 0 : goto out;
105 : :
106 : : /* if link status is down no point in checking to see if pf is up */
107 : 0 : links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
108 [ # # ]: 0 : if (!(links_reg & IXGBE_LINKS_UP))
109 : 0 : goto out;
110 : :
111 : : /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
112 : : * before the link status is correct
113 : : */
114 [ # # ]: 0 : if (mac->type == ixgbe_mac_82599_vf) {
115 : : int i;
116 : :
117 [ # # ]: 0 : for (i = 0; i < 5; i++) {
118 : 0 : DELAY(100);
119 : 0 : links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
120 : :
121 [ # # ]: 0 : if (!(links_reg & IXGBE_LINKS_UP))
122 : 0 : goto out;
123 : : }
124 : : }
125 : :
126 [ # # # # : 0 : switch (links_reg & IXGBE_LINKS_SPEED_82599) {
# ]
127 : 0 : case IXGBE_LINKS_SPEED_10G_82599:
128 : 0 : *speed = IXGBE_LINK_SPEED_10GB_FULL;
129 [ # # ]: 0 : if (hw->mac.type >= ixgbe_mac_X550) {
130 [ # # ]: 0 : if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
131 : 0 : *speed = IXGBE_LINK_SPEED_2_5GB_FULL;
132 : : }
133 : : break;
134 : 0 : case IXGBE_LINKS_SPEED_1G_82599:
135 : 0 : *speed = IXGBE_LINK_SPEED_1GB_FULL;
136 : 0 : break;
137 : 0 : case IXGBE_LINKS_SPEED_100_82599:
138 : 0 : *speed = IXGBE_LINK_SPEED_100_FULL;
139 [ # # ]: 0 : if (hw->mac.type == ixgbe_mac_X550) {
140 [ # # ]: 0 : if (links_reg & IXGBE_LINKS_SPEED_NON_STD)
141 : 0 : *speed = IXGBE_LINK_SPEED_5GB_FULL;
142 : : }
143 : : break;
144 : 0 : case IXGBE_LINKS_SPEED_10_X550EM_A:
145 : 0 : *speed = IXGBE_LINK_SPEED_UNKNOWN;
146 : : /* Reserved for pre-x550 devices */
147 [ # # ]: 0 : if (hw->mac.type >= ixgbe_mac_X550)
148 : 0 : *speed = IXGBE_LINK_SPEED_10_FULL;
149 : : break;
150 : 0 : default:
151 : 0 : *speed = IXGBE_LINK_SPEED_UNKNOWN;
152 : : }
153 : :
154 : : /* if we passed all the tests above then the link is up and we no
155 : : * longer need to check for link
156 : : */
157 : 0 : mac->get_link_status = false;
158 : :
159 : 0 : out:
160 : 0 : *link_up = !mac->get_link_status;
161 : 0 : return IXGBE_SUCCESS;
162 : : }
163 : :
164 : : /**
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
168 : : * Hyper-V variant.
169 : : **/
170 : 0 : static s32 ixgbevf_hv_set_rlpml_vf(struct ixgbe_hw *hw, u16 max_size)
171 : : {
172 : : u32 reg;
173 : :
174 : : /* If we are on Hyper-V, we implement this functionality
175 : : * differently.
176 : : */
177 : 0 : reg = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(0));
178 : : /* CRC == 4 */
179 : 0 : reg |= ((max_size + 4) | IXGBE_RXDCTL_RLPML_EN);
180 : 0 : IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(0), reg);
181 : :
182 : 0 : return IXGBE_SUCCESS;
183 : : }
184 : :
185 : : /**
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.
190 : : **/
191 : 0 : static int ixgbevf_hv_negotiate_api_version_vf(struct ixgbe_hw *hw, int api)
192 : : {
193 : : UNREFERENCED_1PARAMETER(hw);
194 : :
195 : : /* Hyper-V only supports api version ixgbe_mbox_api_10 */
196 [ # # ]: 0 : if (api != ixgbe_mbox_api_10)
197 : 0 : return IXGBE_ERR_INVALID_ARGUMENT;
198 : :
199 : : return IXGBE_SUCCESS;
200 : : }
201 : :
202 : : /**
203 : : * ixgbevf_hv_init_ops_vf - Initialize the pointers for vf
204 : : * @hw: pointer to hardware structure
205 : : *
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.
210 : : **/
211 : 0 : s32 ixgbevf_hv_init_ops_vf(struct ixgbe_hw *hw)
212 : : {
213 : : /* Set defaults for VF then override applicable Hyper-V
214 : : * specific functions
215 : : */
216 : 0 : ixgbe_init_ops_vf(hw);
217 : :
218 : 0 : hw->mac.ops.reset_hw = ixgbevf_hv_reset_hw_vf;
219 : 0 : hw->mac.ops.check_link = ixgbevf_hv_check_mac_link_vf;
220 : 0 : hw->mac.ops.negotiate_api_version = ixgbevf_hv_negotiate_api_version_vf;
221 : 0 : hw->mac.ops.set_rar = ixgbevf_hv_set_rar_vf;
222 : 0 : hw->mac.ops.update_mc_addr_list = ixgbevf_hv_update_mc_addr_list_vf;
223 : 0 : hw->mac.ops.update_xcast_mode = ixgbevf_hv_update_xcast_mode;
224 : 0 : hw->mac.ops.set_uc_addr = ixgbevf_hv_set_uc_addr_vf;
225 : 0 : hw->mac.ops.set_vfta = ixgbevf_hv_set_vfta_vf;
226 : 0 : hw->mac.ops.set_rlpml = ixgbevf_hv_set_rlpml_vf;
227 : :
228 : 0 : return IXGBE_SUCCESS;
229 : : }
|