e1000_vf.c revision 302408
1202283Slulf/******************************************************************************
2202283Slulf
3202283Slulf  Copyright (c) 2001-2015, Intel Corporation
4202283Slulf  All rights reserved.
5202283Slulf
6202283Slulf  Redistribution and use in source and binary forms, with or without
7202283Slulf  modification, are permitted provided that the following conditions are met:
8202283Slulf
9202283Slulf   1. Redistributions of source code must retain the above copyright notice,
10202283Slulf      this list of conditions and the following disclaimer.
11202283Slulf
12202283Slulf   2. Redistributions in binary form must reproduce the above copyright
13202283Slulf      notice, this list of conditions and the following disclaimer in the
14202283Slulf      documentation and/or other materials provided with the distribution.
15202283Slulf
16202283Slulf   3. Neither the name of the Intel Corporation nor the names of its
17202283Slulf      contributors may be used to endorse or promote products derived from
18202283Slulf      this software without specific prior written permission.
19202283Slulf
20202283Slulf  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21202283Slulf  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22202283Slulf  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23202283Slulf  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24202283Slulf  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25202283Slulf  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26202283Slulf  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27202283Slulf  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28202283Slulf  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29202283Slulf  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30262723Spfg  POSSIBILITY OF SUCH DAMAGE.
31202283Slulf
32202283Slulf******************************************************************************/
33217703Sjhb/*$FreeBSD: stable/11/sys/dev/e1000/e1000_vf.c 286833 2015-08-16 20:13:58Z sbruno $*/
34217703Sjhb
35217703Sjhb
36217703Sjhb#include "e1000_api.h"
37217703Sjhb
38217703Sjhb
39217703Sjhbstatic s32 e1000_init_phy_params_vf(struct e1000_hw *hw);
40217703Sjhbstatic s32 e1000_init_nvm_params_vf(struct e1000_hw *hw);
41217703Sjhbstatic void e1000_release_vf(struct e1000_hw *hw);
42217703Sjhbstatic s32 e1000_acquire_vf(struct e1000_hw *hw);
43217703Sjhbstatic s32 e1000_setup_link_vf(struct e1000_hw *hw);
44217703Sjhbstatic s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw);
45217703Sjhbstatic s32 e1000_init_mac_params_vf(struct e1000_hw *hw);
46217703Sjhbstatic s32 e1000_check_for_link_vf(struct e1000_hw *hw);
47259904Spfgstatic s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
48259904Spfg				     u16 *duplex);
49217703Sjhbstatic s32 e1000_init_hw_vf(struct e1000_hw *hw);
50217703Sjhbstatic s32 e1000_reset_hw_vf(struct e1000_hw *hw);
51217703Sjhbstatic void e1000_update_mc_addr_list_vf(struct e1000_hw *hw, u8 *, u32);
52202283Slulfstatic int  e1000_rar_set_vf(struct e1000_hw *, u8 *, u32);
53261311Spfgstatic s32 e1000_read_mac_addr_vf(struct e1000_hw *);
54296992Spfg
55261311Spfg/**
56261311Spfg *  e1000_init_phy_params_vf - Inits PHY params
57202283Slulf *  @hw: pointer to the HW structure
58262723Spfg *
59262723Spfg *  Doesn't do much - there's no PHY available to the VF.
60262723Spfg **/
61262723Spfgstatic s32 e1000_init_phy_params_vf(struct e1000_hw *hw)
62262723Spfg{
63262723Spfg	DEBUGFUNC("e1000_init_phy_params_vf");
64262723Spfg	hw->phy.type = e1000_phy_vf;
65262723Spfg	hw->phy.ops.acquire = e1000_acquire_vf;
66296992Spfg	hw->phy.ops.release = e1000_release_vf;
67262723Spfg
68262723Spfg	return E1000_SUCCESS;
69262723Spfg}
70262723Spfg
71262723Spfg/**
72262723Spfg *  e1000_init_nvm_params_vf - Inits NVM params
73262723Spfg *  @hw: pointer to the HW structure
74305494Spfg *
75262723Spfg *  Doesn't do much - there's no NVM available to the VF.
76305494Spfg **/
77305494Spfgstatic s32 e1000_init_nvm_params_vf(struct e1000_hw *hw)
78244475Spfg{
79232703Spfg	DEBUGFUNC("e1000_init_nvm_params_vf");
80232703Spfg	hw->nvm.type = e1000_nvm_none;
81232703Spfg	hw->nvm.ops.acquire = e1000_acquire_vf;
82232703Spfg	hw->nvm.ops.release = e1000_release_vf;
83262723Spfg
84262723Spfg	return E1000_SUCCESS;
85262723Spfg}
86202283Slulf
87262723Spfg/**
88251344Spfg *  e1000_init_mac_params_vf - Inits MAC params
89262723Spfg *  @hw: pointer to the HW structure
90254260Spfg **/
91232703Spfgstatic s32 e1000_init_mac_params_vf(struct e1000_hw *hw)
92202283Slulf{
93251809Spfg	struct e1000_mac_info *mac = &hw->mac;
94251809Spfg
95251809Spfg	DEBUGFUNC("e1000_init_mac_params_vf");
96251809Spfg
97251809Spfg	/* Set media type */
98251809Spfg	/*
99251809Spfg	 * Virtual functions don't care what they're media type is as they
100262723Spfg	 * have no direct access to the PHY, or the media.  That is handled
101251809Spfg	 * by the physical function driver.
102251809Spfg	 */
103202283Slulf	hw->phy.media_type = e1000_media_type_unknown;
104202283Slulf
105202283Slulf	/* No ASF features for the VF driver */
106221126Sjhb	mac->asf_firmware_present = FALSE;
107221126Sjhb	/* ARC subsystem not supported */
108245121Spfg	mac->arc_subsystem_valid = FALSE;
109245121Spfg	/* Disable adaptive IFS mode so the generic funcs don't do anything */
110245121Spfg	mac->adaptive_ifs = FALSE;
111245121Spfg	/* VF's have no MTA Registers - PF feature only */
112245121Spfg	mac->mta_reg_count = 128;
113221126Sjhb	/* VF's have no access to RAR entries  */
114221126Sjhb	mac->rar_entry_count = 1;
115221126Sjhb
116221126Sjhb	/* Function pointers */
117232703Spfg	/* link setup */
118221126Sjhb	mac->ops.setup_link = e1000_setup_link_vf;
119221126Sjhb	/* bus type/speed/width */
120245121Spfg	mac->ops.get_bus_info = e1000_get_bus_info_pcie_vf;
121245121Spfg	/* reset */
122245121Spfg	mac->ops.reset_hw = e1000_reset_hw_vf;
123243652Spfg	/* hw initialization */
124245121Spfg	mac->ops.init_hw = e1000_init_hw_vf;
125221126Sjhb	/* check for link */
126221126Sjhb	mac->ops.check_for_link = e1000_check_for_link_vf;
127262723Spfg	/* link info */
128245121Spfg	mac->ops.get_link_up_info = e1000_get_link_up_info_vf;
129245121Spfg	/* multicast address update */
130245121Spfg	mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_vf;
131262723Spfg	/* set mac address */
132262723Spfg	mac->ops.rar_set = e1000_rar_set_vf;
133262723Spfg	/* read mac address */
134262723Spfg	mac->ops.read_mac_addr = e1000_read_mac_addr_vf;
135262723Spfg
136262723Spfg
137297480Skevlo	return E1000_SUCCESS;
138202283Slulf}
139202283Slulf
140217585Sjhb/**
141202283Slulf *  e1000_init_function_pointers_vf - Inits function pointers
142 *  @hw: pointer to the HW structure
143 **/
144void e1000_init_function_pointers_vf(struct e1000_hw *hw)
145{
146	DEBUGFUNC("e1000_init_function_pointers_vf");
147
148	hw->mac.ops.init_params = e1000_init_mac_params_vf;
149	hw->nvm.ops.init_params = e1000_init_nvm_params_vf;
150	hw->phy.ops.init_params = e1000_init_phy_params_vf;
151	hw->mbx.ops.init_params = e1000_init_mbx_params_vf;
152}
153
154/**
155 *  e1000_acquire_vf - Acquire rights to access PHY or NVM.
156 *  @hw: pointer to the HW structure
157 *
158 *  There is no PHY or NVM so we want all attempts to acquire these to fail.
159 *  In addition, the MAC registers to access PHY/NVM don't exist so we don't
160 *  even want any SW to attempt to use them.
161 **/
162static s32 e1000_acquire_vf(struct e1000_hw E1000_UNUSEDARG *hw)
163{
164	return -E1000_ERR_PHY;
165}
166
167/**
168 *  e1000_release_vf - Release PHY or NVM
169 *  @hw: pointer to the HW structure
170 *
171 *  There is no PHY or NVM so we want all attempts to acquire these to fail.
172 *  In addition, the MAC registers to access PHY/NVM don't exist so we don't
173 *  even want any SW to attempt to use them.
174 **/
175static void e1000_release_vf(struct e1000_hw E1000_UNUSEDARG *hw)
176{
177	return;
178}
179
180/**
181 *  e1000_setup_link_vf - Sets up link.
182 *  @hw: pointer to the HW structure
183 *
184 *  Virtual functions cannot change link.
185 **/
186static s32 e1000_setup_link_vf(struct e1000_hw E1000_UNUSEDARG *hw)
187{
188	DEBUGFUNC("e1000_setup_link_vf");
189
190	return E1000_SUCCESS;
191}
192
193/**
194 *  e1000_get_bus_info_pcie_vf - Gets the bus info.
195 *  @hw: pointer to the HW structure
196 *
197 *  Virtual functions are not really on their own bus.
198 **/
199static s32 e1000_get_bus_info_pcie_vf(struct e1000_hw *hw)
200{
201	struct e1000_bus_info *bus = &hw->bus;
202
203	DEBUGFUNC("e1000_get_bus_info_pcie_vf");
204
205	/* Do not set type PCI-E because we don't want disable master to run */
206	bus->type = e1000_bus_type_reserved;
207	bus->speed = e1000_bus_speed_2500;
208
209	return 0;
210}
211
212/**
213 *  e1000_get_link_up_info_vf - Gets link info.
214 *  @hw: pointer to the HW structure
215 *  @speed: pointer to 16 bit value to store link speed.
216 *  @duplex: pointer to 16 bit value to store duplex.
217 *
218 *  Since we cannot read the PHY and get accurate link info, we must rely upon
219 *  the status register's data which is often stale and inaccurate.
220 **/
221static s32 e1000_get_link_up_info_vf(struct e1000_hw *hw, u16 *speed,
222				     u16 *duplex)
223{
224	s32 status;
225
226	DEBUGFUNC("e1000_get_link_up_info_vf");
227
228	status = E1000_READ_REG(hw, E1000_STATUS);
229	if (status & E1000_STATUS_SPEED_1000) {
230		*speed = SPEED_1000;
231		DEBUGOUT("1000 Mbs, ");
232	} else if (status & E1000_STATUS_SPEED_100) {
233		*speed = SPEED_100;
234		DEBUGOUT("100 Mbs, ");
235	} else {
236		*speed = SPEED_10;
237		DEBUGOUT("10 Mbs, ");
238	}
239
240	if (status & E1000_STATUS_FD) {
241		*duplex = FULL_DUPLEX;
242		DEBUGOUT("Full Duplex\n");
243	} else {
244		*duplex = HALF_DUPLEX;
245		DEBUGOUT("Half Duplex\n");
246	}
247
248	return E1000_SUCCESS;
249}
250
251/**
252 *  e1000_reset_hw_vf - Resets the HW
253 *  @hw: pointer to the HW structure
254 *
255 *  VF's provide a function level reset. This is done using bit 26 of ctrl_reg.
256 *  This is all the reset we can perform on a VF.
257 **/
258static s32 e1000_reset_hw_vf(struct e1000_hw *hw)
259{
260	struct e1000_mbx_info *mbx = &hw->mbx;
261	u32 timeout = E1000_VF_INIT_TIMEOUT;
262	s32 ret_val = -E1000_ERR_MAC_INIT;
263	u32 ctrl, msgbuf[3];
264	u8 *addr = (u8 *)(&msgbuf[1]);
265
266	DEBUGFUNC("e1000_reset_hw_vf");
267
268	DEBUGOUT("Issuing a function level reset to MAC\n");
269	ctrl = E1000_READ_REG(hw, E1000_CTRL);
270	E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
271
272	/* we cannot reset while the RSTI / RSTD bits are asserted */
273	while (!mbx->ops.check_for_rst(hw, 0) && timeout) {
274		timeout--;
275		usec_delay(5);
276	}
277
278	if (timeout) {
279		/* mailbox timeout can now become active */
280		mbx->timeout = E1000_VF_MBX_INIT_TIMEOUT;
281
282		msgbuf[0] = E1000_VF_RESET;
283		mbx->ops.write_posted(hw, msgbuf, 1, 0);
284
285		msec_delay(10);
286
287		/* set our "perm_addr" based on info provided by PF */
288		ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
289		if (!ret_val) {
290			if (msgbuf[0] == (E1000_VF_RESET |
291			    E1000_VT_MSGTYPE_ACK))
292				memcpy(hw->mac.perm_addr, addr, 6);
293			else
294				ret_val = -E1000_ERR_MAC_INIT;
295		}
296	}
297
298	return ret_val;
299}
300
301/**
302 *  e1000_init_hw_vf - Inits the HW
303 *  @hw: pointer to the HW structure
304 *
305 *  Not much to do here except clear the PF Reset indication if there is one.
306 **/
307static s32 e1000_init_hw_vf(struct e1000_hw *hw)
308{
309	DEBUGFUNC("e1000_init_hw_vf");
310
311	/* attempt to set and restore our mac address */
312	e1000_rar_set_vf(hw, hw->mac.addr, 0);
313
314	return E1000_SUCCESS;
315}
316
317/**
318 *  e1000_rar_set_vf - set device MAC address
319 *  @hw: pointer to the HW structure
320 *  @addr: pointer to the receive address
321 *  @index receive address array register
322 **/
323static int e1000_rar_set_vf(struct e1000_hw *hw, u8 *addr,
324			     u32 E1000_UNUSEDARG index)
325{
326	struct e1000_mbx_info *mbx = &hw->mbx;
327	u32 msgbuf[3];
328	u8 *msg_addr = (u8 *)(&msgbuf[1]);
329	s32 ret_val;
330
331	memset(msgbuf, 0, 12);
332	msgbuf[0] = E1000_VF_SET_MAC_ADDR;
333	memcpy(msg_addr, addr, 6);
334	ret_val = mbx->ops.write_posted(hw, msgbuf, 3, 0);
335
336	if (!ret_val)
337		ret_val = mbx->ops.read_posted(hw, msgbuf, 3, 0);
338
339	msgbuf[0] &= ~E1000_VT_MSGTYPE_CTS;
340
341	/* if nacked the address was rejected, use "perm_addr" */
342	if (!ret_val &&
343	    (msgbuf[0] == (E1000_VF_SET_MAC_ADDR | E1000_VT_MSGTYPE_NACK)))
344		e1000_read_mac_addr_vf(hw);
345
346	return E1000_SUCCESS;
347}
348
349/**
350 *  e1000_hash_mc_addr_vf - Generate a multicast hash value
351 *  @hw: pointer to the HW structure
352 *  @mc_addr: pointer to a multicast address
353 *
354 *  Generates a multicast address hash value which is used to determine
355 *  the multicast filter table array address and new table value.
356 **/
357static u32 e1000_hash_mc_addr_vf(struct e1000_hw *hw, u8 *mc_addr)
358{
359	u32 hash_value, hash_mask;
360	u8 bit_shift = 0;
361
362	DEBUGFUNC("e1000_hash_mc_addr_generic");
363
364	/* Register count multiplied by bits per register */
365	hash_mask = (hw->mac.mta_reg_count * 32) - 1;
366
367	/*
368	 * The bit_shift is the number of left-shifts
369	 * where 0xFF would still fall within the hash mask.
370	 */
371	while (hash_mask >> bit_shift != 0xFF)
372		bit_shift++;
373
374	hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
375				  (((u16) mc_addr[5]) << bit_shift)));
376
377	return hash_value;
378}
379
380static void e1000_write_msg_read_ack(struct e1000_hw *hw,
381				     u32 *msg, u16 size)
382{
383	struct e1000_mbx_info *mbx = &hw->mbx;
384	u32 retmsg[E1000_VFMAILBOX_SIZE];
385	s32 retval = mbx->ops.write_posted(hw, msg, size, 0);
386
387	if (!retval)
388		mbx->ops.read_posted(hw, retmsg, E1000_VFMAILBOX_SIZE, 0);
389}
390
391/**
392 *  e1000_update_mc_addr_list_vf - Update Multicast addresses
393 *  @hw: pointer to the HW structure
394 *  @mc_addr_list: array of multicast addresses to program
395 *  @mc_addr_count: number of multicast addresses to program
396 *
397 *  Updates the Multicast Table Array.
398 *  The caller must have a packed mc_addr_list of multicast addresses.
399 **/
400void e1000_update_mc_addr_list_vf(struct e1000_hw *hw,
401				  u8 *mc_addr_list, u32 mc_addr_count)
402{
403	u32 msgbuf[E1000_VFMAILBOX_SIZE];
404	u16 *hash_list = (u16 *)&msgbuf[1];
405	u32 hash_value;
406	u32 i;
407
408	DEBUGFUNC("e1000_update_mc_addr_list_vf");
409
410	/* Each entry in the list uses 1 16 bit word.  We have 30
411	 * 16 bit words available in our HW msg buffer (minus 1 for the
412	 * msg type).  That's 30 hash values if we pack 'em right.  If
413	 * there are more than 30 MC addresses to add then punt the
414	 * extras for now and then add code to handle more than 30 later.
415	 * It would be unusual for a server to request that many multi-cast
416	 * addresses except for in large enterprise network environments.
417	 */
418
419	DEBUGOUT1("MC Addr Count = %d\n", mc_addr_count);
420
421	if (mc_addr_count > 30) {
422		msgbuf[0] |= E1000_VF_SET_MULTICAST_OVERFLOW;
423		mc_addr_count = 30;
424	}
425
426	msgbuf[0] = E1000_VF_SET_MULTICAST;
427	msgbuf[0] |= mc_addr_count << E1000_VT_MSGINFO_SHIFT;
428
429	for (i = 0; i < mc_addr_count; i++) {
430		hash_value = e1000_hash_mc_addr_vf(hw, mc_addr_list);
431		DEBUGOUT1("Hash value = 0x%03X\n", hash_value);
432		hash_list[i] = hash_value & 0x0FFF;
433		mc_addr_list += ETH_ADDR_LEN;
434	}
435
436	e1000_write_msg_read_ack(hw, msgbuf, E1000_VFMAILBOX_SIZE);
437}
438
439/**
440 *  e1000_vfta_set_vf - Set/Unset vlan filter table address
441 *  @hw: pointer to the HW structure
442 *  @vid: determines the vfta register and bit to set/unset
443 *  @set: if TRUE then set bit, else clear bit
444 **/
445void e1000_vfta_set_vf(struct e1000_hw *hw, u16 vid, bool set)
446{
447	u32 msgbuf[2];
448
449	msgbuf[0] = E1000_VF_SET_VLAN;
450	msgbuf[1] = vid;
451	/* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
452	if (set)
453		msgbuf[0] |= E1000_VF_SET_VLAN_ADD;
454
455	e1000_write_msg_read_ack(hw, msgbuf, 2);
456}
457
458/** e1000_rlpml_set_vf - Set the maximum receive packet length
459 *  @hw: pointer to the HW structure
460 *  @max_size: value to assign to max frame size
461 **/
462void e1000_rlpml_set_vf(struct e1000_hw *hw, u16 max_size)
463{
464	u32 msgbuf[2];
465
466	msgbuf[0] = E1000_VF_SET_LPE;
467	msgbuf[1] = max_size;
468
469	e1000_write_msg_read_ack(hw, msgbuf, 2);
470}
471
472/**
473 *  e1000_promisc_set_vf - Set flags for Unicast or Multicast promisc
474 *  @hw: pointer to the HW structure
475 *  @uni: boolean indicating unicast promisc status
476 *  @multi: boolean indicating multicast promisc status
477 **/
478s32 e1000_promisc_set_vf(struct e1000_hw *hw, enum e1000_promisc_type type)
479{
480	struct e1000_mbx_info *mbx = &hw->mbx;
481	u32 msgbuf = E1000_VF_SET_PROMISC;
482	s32 ret_val;
483
484	switch (type) {
485	case e1000_promisc_multicast:
486		msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
487		break;
488	case e1000_promisc_enabled:
489		msgbuf |= E1000_VF_SET_PROMISC_MULTICAST;
490	case e1000_promisc_unicast:
491		msgbuf |= E1000_VF_SET_PROMISC_UNICAST;
492	case e1000_promisc_disabled:
493		break;
494	default:
495		return -E1000_ERR_MAC_INIT;
496	}
497
498	 ret_val = mbx->ops.write_posted(hw, &msgbuf, 1, 0);
499
500	if (!ret_val)
501		ret_val = mbx->ops.read_posted(hw, &msgbuf, 1, 0);
502
503	if (!ret_val && !(msgbuf & E1000_VT_MSGTYPE_ACK))
504		ret_val = -E1000_ERR_MAC_INIT;
505
506	return ret_val;
507}
508
509/**
510 *  e1000_read_mac_addr_vf - Read device MAC address
511 *  @hw: pointer to the HW structure
512 **/
513static s32 e1000_read_mac_addr_vf(struct e1000_hw *hw)
514{
515	int i;
516
517	for (i = 0; i < ETH_ADDR_LEN; i++)
518		hw->mac.addr[i] = hw->mac.perm_addr[i];
519
520	return E1000_SUCCESS;
521}
522
523/**
524 *  e1000_check_for_link_vf - Check for link for a virtual interface
525 *  @hw: pointer to the HW structure
526 *
527 *  Checks to see if the underlying PF is still talking to the VF and
528 *  if it is then it reports the link state to the hardware, otherwise
529 *  it reports link down and returns an error.
530 **/
531static s32 e1000_check_for_link_vf(struct e1000_hw *hw)
532{
533	struct e1000_mbx_info *mbx = &hw->mbx;
534	struct e1000_mac_info *mac = &hw->mac;
535	s32 ret_val = E1000_SUCCESS;
536	u32 in_msg = 0;
537
538	DEBUGFUNC("e1000_check_for_link_vf");
539
540	/*
541	 * We only want to run this if there has been a rst asserted.
542	 * in this case that could mean a link change, device reset,
543	 * or a virtual function reset
544	 */
545
546	/* If we were hit with a reset or timeout drop the link */
547	if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout)
548		mac->get_link_status = TRUE;
549
550	if (!mac->get_link_status)
551		goto out;
552
553	/* if link status is down no point in checking to see if pf is up */
554	if (!(E1000_READ_REG(hw, E1000_STATUS) & E1000_STATUS_LU))
555		goto out;
556
557	/* if the read failed it could just be a mailbox collision, best wait
558	 * until we are called again and don't report an error */
559	if (mbx->ops.read(hw, &in_msg, 1, 0))
560		goto out;
561
562	/* if incoming message isn't clear to send we are waiting on response */
563	if (!(in_msg & E1000_VT_MSGTYPE_CTS)) {
564		/* message is not CTS and is NACK we have lost CTS status */
565		if (in_msg & E1000_VT_MSGTYPE_NACK)
566			ret_val = -E1000_ERR_MAC_INIT;
567		goto out;
568	}
569
570	/* at this point we know the PF is talking to us, check and see if
571	 * we are still accepting timeout or if we had a timeout failure.
572	 * if we failed then we will need to reinit */
573	if (!mbx->timeout) {
574		ret_val = -E1000_ERR_MAC_INIT;
575		goto out;
576	}
577
578	/* if we passed all the tests above then the link is up and we no
579	 * longer need to check for link */
580	mac->get_link_status = FALSE;
581
582out:
583	return ret_val;
584}
585
586