]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/dpdk/drivers/net/ixgbe/base/ixgbe_hv_vf.c
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / seastar / dpdk / drivers / net / ixgbe / base / ixgbe_hv_vf.c
1 /*******************************************************************************
2
3 Copyright (c) 2001-2015, Intel Corporation
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
8
9 1. Redistributions of source code must retain the above copyright notice,
10 this list of conditions and the following disclaimer.
11
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.
15
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.
19
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.
31
32 ***************************************************************************/
33
34 #include "ixgbe_vf.h"
35 #include "ixgbe_hv_vf.h"
36
37 /**
38 * Hyper-V variant - just a stub.
39 */
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,
42 bool clear)
43 {
44 UNREFERENCED_5PARAMETER(hw, mc_addr_list, mc_addr_count, next, clear);
45
46 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
47 }
48
49 /**
50 * Hyper-V variant - just a stub.
51 */
52 static s32 ixgbevf_hv_update_xcast_mode(struct ixgbe_hw *hw, int xcast_mode)
53 {
54 UNREFERENCED_2PARAMETER(hw, xcast_mode);
55
56 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
57 }
58
59 /**
60 * Hyper-V variant - just a stub.
61 */
62 static s32 ixgbevf_hv_set_vfta_vf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
63 bool vlan_on, bool vlvf_bypass)
64 {
65 UNREFERENCED_5PARAMETER(hw, vlan, vind, vlan_on, vlvf_bypass);
66
67 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
68 }
69
70 static s32 ixgbevf_hv_set_uc_addr_vf(struct ixgbe_hw *hw, u32 index, u8 *addr)
71 {
72 UNREFERENCED_3PARAMETER(hw, index, addr);
73
74 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
75 }
76
77 /**
78 * Hyper-V variant - just a stub.
79 */
80 static s32 ixgbevf_hv_reset_hw_vf(struct ixgbe_hw *hw)
81 {
82 UNREFERENCED_PARAMETER(hw);
83
84 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
85 }
86
87 /**
88 * Hyper-V variant - just a stub.
89 */
90 static s32 ixgbevf_hv_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 *addr, u32 vlan, u32 vind)
91 {
92 UNREFERENCED_5PARAMETER(hw, index, addr, vlan, vind);
93
94 return IXGBE_ERR_FEATURE_NOT_SUPPORTED;
95 }
96
97 /**
98 * Hyper-V variant; there is no mailbox communication.
99 */
100 static s32 ixgbevf_hv_check_mac_link_vf(struct ixgbe_hw *hw,
101 ixgbe_link_speed *speed,
102 bool *link_up,
103 bool autoneg_wait_to_complete)
104 {
105 struct ixgbe_mbx_info *mbx = &hw->mbx;
106 struct ixgbe_mac_info *mac = &hw->mac;
107 u32 links_reg;
108 UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
109
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;
113
114 if (!mac->get_link_status)
115 goto out;
116
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))
120 goto out;
121
122 /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs
123 * before the link status is correct
124 */
125 if (mac->type == ixgbe_mac_82599_vf) {
126 int i;
127
128 for (i = 0; i < 5; i++) {
129 DELAY(100);
130 links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS);
131
132 if (!(links_reg & IXGBE_LINKS_UP))
133 goto out;
134 }
135 }
136
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;
143 }
144 break;
145 case IXGBE_LINKS_SPEED_1G_82599:
146 *speed = IXGBE_LINK_SPEED_1GB_FULL;
147 break;
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;
153 }
154 break;
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;
160 break;
161 default:
162 *speed = IXGBE_LINK_SPEED_UNKNOWN;
163 }
164
165 /* if we passed all the tests above then the link is up and we no
166 * longer need to check for link
167 */
168 mac->get_link_status = false;
169
170 out:
171 *link_up = !mac->get_link_status;
172 return IXGBE_SUCCESS;
173 }
174
175 /**
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
179 * Hyper-V variant.
180 **/
181 static s32 ixgbevf_hv_set_rlpml_vf(struct ixgbe_hw *hw, u16 max_size)
182 {
183 u32 reg;
184
185 /* If we are on Hyper-V, we implement this functionality
186 * differently.
187 */
188 reg = IXGBE_READ_REG(hw, IXGBE_VFRXDCTL(0));
189 /* CRC == 4 */
190 reg |= ((max_size + 4) | IXGBE_RXDCTL_RLPML_EN);
191 IXGBE_WRITE_REG(hw, IXGBE_VFRXDCTL(0), reg);
192
193 return IXGBE_SUCCESS;
194 }
195
196 /**
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.
201 **/
202 static int ixgbevf_hv_negotiate_api_version_vf(struct ixgbe_hw *hw, int api)
203 {
204 UNREFERENCED_1PARAMETER(hw);
205
206 /* Hyper-V only supports api version ixgbe_mbox_api_10 */
207 if (api != ixgbe_mbox_api_10)
208 return IXGBE_ERR_INVALID_ARGUMENT;
209
210 return IXGBE_SUCCESS;
211 }
212
213 /**
214 * ixgbevf_hv_init_ops_vf - Initialize the pointers for vf
215 * @hw: pointer to hardware structure
216 *
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.
221 **/
222 s32 ixgbevf_hv_init_ops_vf(struct ixgbe_hw *hw)
223 {
224 /* Set defaults for VF then override applicable Hyper-V
225 * specific functions
226 */
227 ixgbe_init_ops_vf(hw);
228
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;
238
239 return IXGBE_SUCCESS;
240 }