1e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny/* Intel(R) Gigabit Ethernet Linux driver
2e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * Copyright(c) 2007-2014 Intel Corporation.
3e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny *
4e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * This program is free software; you can redistribute it and/or modify it
5e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * under the terms and conditions of the GNU General Public License,
6e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * version 2, as published by the Free Software Foundation.
7e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny *
8e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * This program is distributed in the hope it will be useful, but WITHOUT
9e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * more details.
12e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny *
13e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * You should have received a copy of the GNU General Public License along with
14e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * this program; if not, see <http://www.gnu.org/licenses/>.
15e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny *
16e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * The full GNU General Public License is included in this distribution in
17e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * the file called "COPYING".
18e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny *
19e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * Contact Information:
20e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
21e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
22e52c0f960cbc2c691cbb809ac0bfec2becfe6da9Carolyn Wyborny */
234ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
244ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck#include "e1000_mbx.h"
254ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
264ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
274ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_read_mbx - Reads a message from the mailbox
284ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
294ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @msg: The message buffer
304ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @size: Length of buffer
314ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @mbx_id: id of mailbox to read
324ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
33bfb9035c98906aafcd3cf22694fba2550997bf53Joe Perches *  returns SUCCESS if it successfully read message from buffer
344ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
354ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duycks32 igb_read_mbx(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id)
364ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
374ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	struct e1000_mbx_info *mbx = &hw->mbx;
384ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
394ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
404ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	/* limit read to size of mailbox */
414ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (size > mbx->size)
424ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		size = mbx->size;
434ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
444ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (mbx->ops.read)
454ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = mbx->ops.read(hw, msg, size, mbx_id);
464ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
474ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
484ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
494ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
504ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
514ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_write_mbx - Write a message to the mailbox
524ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
534ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @msg: The message buffer
544ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @size: Length of buffer
554ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @mbx_id: id of mailbox to write
564ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
574ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if it successfully copied message into the buffer
584ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
594ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duycks32 igb_write_mbx(struct e1000_hw *hw, u32 *msg, u16 size, u16 mbx_id)
604ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
614ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	struct e1000_mbx_info *mbx = &hw->mbx;
624ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	s32 ret_val = 0;
634ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
644ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (size > mbx->size)
654ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = -E1000_ERR_MBX;
664ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
674ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	else if (mbx->ops.write)
684ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = mbx->ops.write(hw, msg, size, mbx_id);
694ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
704ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
714ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
724ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
734ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
744ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_check_for_msg - checks to see if someone sent us mail
754ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
764ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @mbx_id: id of mailbox to check
774ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
784ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if the Status bit was found or else ERR_MBX
794ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
804ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duycks32 igb_check_for_msg(struct e1000_hw *hw, u16 mbx_id)
814ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
824ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	struct e1000_mbx_info *mbx = &hw->mbx;
834ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
844ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
854ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (mbx->ops.check_for_msg)
864ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = mbx->ops.check_for_msg(hw, mbx_id);
874ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
884ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
894ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
904ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
914ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
924ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_check_for_ack - checks to see if someone sent us ACK
934ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
944ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @mbx_id: id of mailbox to check
954ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
964ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if the Status bit was found or else ERR_MBX
974ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
984ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duycks32 igb_check_for_ack(struct e1000_hw *hw, u16 mbx_id)
994ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
1004ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	struct e1000_mbx_info *mbx = &hw->mbx;
1014ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
1024ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1034ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (mbx->ops.check_for_ack)
1044ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = mbx->ops.check_for_ack(hw, mbx_id);
1054ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1064ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
1074ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
1084ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1094ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
1104ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_check_for_rst - checks to see if other side has reset
1114ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
1124ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @mbx_id: id of mailbox to check
1134ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
1144ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if the Status bit was found or else ERR_MBX
1154ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
1164ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duycks32 igb_check_for_rst(struct e1000_hw *hw, u16 mbx_id)
1174ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
1184ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	struct e1000_mbx_info *mbx = &hw->mbx;
1194ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
1204ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1214ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (mbx->ops.check_for_rst)
1224ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = mbx->ops.check_for_rst(hw, mbx_id);
1234ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1244ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
1254ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
1264ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1274ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
1284ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_poll_for_msg - Wait for message notification
1294ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
1304ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @mbx_id: id of mailbox to write
1314ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
1324ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if it successfully received a message notification
1334ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
1344ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckstatic s32 igb_poll_for_msg(struct e1000_hw *hw, u16 mbx_id)
1354ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
1364ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	struct e1000_mbx_info *mbx = &hw->mbx;
1374ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	int countdown = mbx->timeout;
1384ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1393935358ebcb8320965478c0e8ee070e1d65851c8Alexander Duyck	if (!countdown || !mbx->ops.check_for_msg)
1404ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		goto out;
1414ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1423272686c98da64d6eeaa2434782f42270b110758Alexander Duyck	while (countdown && mbx->ops.check_for_msg(hw, mbx_id)) {
1433935358ebcb8320965478c0e8ee070e1d65851c8Alexander Duyck		countdown--;
1444ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		if (!countdown)
1454ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck			break;
1464ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		udelay(mbx->usec_delay);
1474ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	}
1483272686c98da64d6eeaa2434782f42270b110758Alexander Duyck
1493272686c98da64d6eeaa2434782f42270b110758Alexander Duyck	/* if we failed, all future posted messages fail until reset */
1503272686c98da64d6eeaa2434782f42270b110758Alexander Duyck	if (!countdown)
1513272686c98da64d6eeaa2434782f42270b110758Alexander Duyck		mbx->timeout = 0;
1524ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckout:
1534ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return countdown ? 0 : -E1000_ERR_MBX;
1544ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
1554ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1564ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
1574ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_poll_for_ack - Wait for message acknowledgement
1584ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
1594ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @mbx_id: id of mailbox to write
1604ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
1614ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if it successfully received a message acknowledgement
1624ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
1634ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckstatic s32 igb_poll_for_ack(struct e1000_hw *hw, u16 mbx_id)
1644ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
1654ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	struct e1000_mbx_info *mbx = &hw->mbx;
1664ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	int countdown = mbx->timeout;
1674ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1683935358ebcb8320965478c0e8ee070e1d65851c8Alexander Duyck	if (!countdown || !mbx->ops.check_for_ack)
1694ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		goto out;
1704ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1713272686c98da64d6eeaa2434782f42270b110758Alexander Duyck	while (countdown && mbx->ops.check_for_ack(hw, mbx_id)) {
1723935358ebcb8320965478c0e8ee070e1d65851c8Alexander Duyck		countdown--;
1734ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		if (!countdown)
1744ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck			break;
1754ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		udelay(mbx->usec_delay);
1764ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	}
1773272686c98da64d6eeaa2434782f42270b110758Alexander Duyck
1783272686c98da64d6eeaa2434782f42270b110758Alexander Duyck	/* if we failed, all future posted messages fail until reset */
1793272686c98da64d6eeaa2434782f42270b110758Alexander Duyck	if (!countdown)
1803272686c98da64d6eeaa2434782f42270b110758Alexander Duyck		mbx->timeout = 0;
1814ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckout:
1824ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return countdown ? 0 : -E1000_ERR_MBX;
1834ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
1844ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
1854ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
1864ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_read_posted_mbx - Wait for message notification and receive message
1874ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
1884ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @msg: The message buffer
1894ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @size: Length of buffer
1904ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @mbx_id: id of mailbox to write
1914ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
1924ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if it successfully received a message notification and
1934ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  copied it into the receive buffer.
1944ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
195b980ac18c95f3251038da7a3826370aff05a7434Jeff Kirsherstatic s32 igb_read_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size,
196b980ac18c95f3251038da7a3826370aff05a7434Jeff Kirsher			       u16 mbx_id)
1974ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
1984ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	struct e1000_mbx_info *mbx = &hw->mbx;
1994ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
2004ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2014ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (!mbx->ops.read)
2024ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		goto out;
2034ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2044ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	ret_val = igb_poll_for_msg(hw, mbx_id);
2054ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2064ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (!ret_val)
2074ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = mbx->ops.read(hw, msg, size, mbx_id);
2084ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckout:
2094ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
2104ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
2114ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2124ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
2134ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_write_posted_mbx - Write a message to the mailbox, wait for ack
2144ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
2154ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @msg: The message buffer
2164ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @size: Length of buffer
2174ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @mbx_id: id of mailbox to write
2184ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
2194ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if it successfully copied message into the buffer and
2204ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  received an ack to that message within delay * timeout period
2214ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
222b980ac18c95f3251038da7a3826370aff05a7434Jeff Kirsherstatic s32 igb_write_posted_mbx(struct e1000_hw *hw, u32 *msg, u16 size,
223b980ac18c95f3251038da7a3826370aff05a7434Jeff Kirsher				u16 mbx_id)
2244ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
2254ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	struct e1000_mbx_info *mbx = &hw->mbx;
2263272686c98da64d6eeaa2434782f42270b110758Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
2274ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2283272686c98da64d6eeaa2434782f42270b110758Alexander Duyck	/* exit if either we can't write or there isn't a defined timeout */
2293272686c98da64d6eeaa2434782f42270b110758Alexander Duyck	if (!mbx->ops.write || !mbx->timeout)
2304ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		goto out;
2314ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2323272686c98da64d6eeaa2434782f42270b110758Alexander Duyck	/* send msg */
2334ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	ret_val = mbx->ops.write(hw, msg, size, mbx_id);
2344ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2354ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	/* if msg sent wait until we receive an ack */
2364ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (!ret_val)
2374ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = igb_poll_for_ack(hw, mbx_id);
2384ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckout:
2394ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
2404ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
2414ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2424ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckstatic s32 igb_check_for_bit_pf(struct e1000_hw *hw, u32 mask)
2434ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
2444ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	u32 mbvficr = rd32(E1000_MBVFICR);
2454ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
2464ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2474ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (mbvficr & mask) {
2484ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = 0;
2494ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		wr32(E1000_MBVFICR, mask);
2504ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	}
2514ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2524ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
2534ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
2544ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2554ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
2564ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_check_for_msg_pf - checks to see if the VF has sent mail
2574ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
2584ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @vf_number: the VF index
2594ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
2604ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if the VF has set the Status bit or else ERR_MBX
2614ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
2624ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckstatic s32 igb_check_for_msg_pf(struct e1000_hw *hw, u16 vf_number)
2634ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
2644ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
2654ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2664ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (!igb_check_for_bit_pf(hw, E1000_MBVFICR_VFREQ_VF1 << vf_number)) {
2674ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = 0;
2684ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		hw->mbx.stats.reqs++;
2694ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	}
2704ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2714ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
2724ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
2734ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2744ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
2754ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_check_for_ack_pf - checks to see if the VF has ACKed
2764ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
2774ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @vf_number: the VF index
2784ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
2794ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if the VF has set the Status bit or else ERR_MBX
2804ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
2814ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckstatic s32 igb_check_for_ack_pf(struct e1000_hw *hw, u16 vf_number)
2824ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
2834ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
2844ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2854ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (!igb_check_for_bit_pf(hw, E1000_MBVFICR_VFACK_VF1 << vf_number)) {
2864ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = 0;
2874ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		hw->mbx.stats.acks++;
2884ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	}
2894ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2904ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
2914ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
2924ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
2934ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
2944ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_check_for_rst_pf - checks to see if the VF has reset
2954ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
2964ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @vf_number: the VF index
2974ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
2984ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if the VF has set the Status bit or else ERR_MBX
2994ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
3004ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckstatic s32 igb_check_for_rst_pf(struct e1000_hw *hw, u16 vf_number)
3014ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
3024ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	u32 vflre = rd32(E1000_VFLRE);
3034ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
3044ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3054ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	if (vflre & (1 << vf_number)) {
3064ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		ret_val = 0;
3074ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		wr32(E1000_VFLRE, (1 << vf_number));
3084ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		hw->mbx.stats.rsts++;
3094ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	}
3104ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3114ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
3124ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
3134ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3144ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
3150acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck *  igb_obtain_mbx_lock_pf - obtain mailbox lock
3160acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck *  @hw: pointer to the HW structure
3170acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck *  @vf_number: the VF index
3180acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck *
3190acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck *  return SUCCESS if we obtained the mailbox lock
3200acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck **/
3210acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyckstatic s32 igb_obtain_mbx_lock_pf(struct e1000_hw *hw, u16 vf_number)
3220acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck{
3230acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	s32 ret_val = -E1000_ERR_MBX;
3240acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	u32 p2v_mailbox;
3250acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck
3260acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	/* Take ownership of the buffer */
3270acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	wr32(E1000_P2VMAILBOX(vf_number), E1000_P2VMAILBOX_PFU);
3280acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck
3290acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	/* reserve mailbox for vf use */
3300acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	p2v_mailbox = rd32(E1000_P2VMAILBOX(vf_number));
3310acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	if (p2v_mailbox & E1000_P2VMAILBOX_PFU)
3320acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck		ret_val = 0;
3330acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck
3340acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	return ret_val;
3350acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck}
3360acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck
3370acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck/**
3384ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_write_mbx_pf - Places a message in the mailbox
3394ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
3404ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @msg: The message buffer
3414ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @size: Length of buffer
3424ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @vf_number: the VF index
3434ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
3444ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  returns SUCCESS if it successfully copied message into the buffer
3454ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
3464ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckstatic s32 igb_write_mbx_pf(struct e1000_hw *hw, u32 *msg, u16 size,
347b980ac18c95f3251038da7a3826370aff05a7434Jeff Kirsher			    u16 vf_number)
3484ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
3490acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	s32 ret_val;
3504ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	u16 i;
3514ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3520acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	/* lock the mailbox to prevent pf/vf race condition */
3530acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	ret_val = igb_obtain_mbx_lock_pf(hw, vf_number);
3540acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	if (ret_val)
3554ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		goto out_no_write;
3564ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3570acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	/* flush msg and acks as we are overwriting the message buffer */
3584ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	igb_check_for_msg_pf(hw, vf_number);
3590acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	igb_check_for_ack_pf(hw, vf_number);
3604ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3614ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	/* copy the caller specified message to the mailbox memory buffer */
3624ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	for (i = 0; i < size; i++)
3634ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		array_wr32(E1000_VMBMEM(vf_number), i, msg[i]);
3644ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3654ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	/* Interrupt VF to tell it a message has been sent and release buffer*/
3664ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	wr32(E1000_P2VMAILBOX(vf_number), E1000_P2VMAILBOX_STS);
3674ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3684ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	/* update stats */
3694ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	hw->mbx.stats.msgs_tx++;
3704ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3714ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckout_no_write:
3724ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
3734ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3744ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
3754ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3764ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
3774ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  igb_read_mbx_pf - Read a message from the mailbox
3784ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
3794ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @msg: The message buffer
3804ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @size: Length of buffer
3814ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @vf_number: the VF index
3824ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
3834ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  This function copies a message from the mailbox buffer to the caller's
3844ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  memory buffer.  The presumption is that the caller knows that there was
3854ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  a message due to a VF request so no polling for message is needed.
3864ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck **/
3874ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckstatic s32 igb_read_mbx_pf(struct e1000_hw *hw, u32 *msg, u16 size,
388b980ac18c95f3251038da7a3826370aff05a7434Jeff Kirsher			   u16 vf_number)
3894ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
3900acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	s32 ret_val;
3914ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	u16 i;
3924ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3930acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	/* lock the mailbox to prevent pf/vf race condition */
3940acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	ret_val = igb_obtain_mbx_lock_pf(hw, vf_number);
3950acb6fde5fc84009be1c7efc0aaa8e69e394a2e2Alexander Duyck	if (ret_val)
3964ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		goto out_no_read;
3974ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
3984ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	/* copy the message to the mailbox memory buffer */
3994ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	for (i = 0; i < size; i++)
4004ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck		msg[i] = array_rd32(E1000_VMBMEM(vf_number), i);
4014ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
4024ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	/* Acknowledge the message and release buffer */
4034ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	wr32(E1000_P2VMAILBOX(vf_number), E1000_P2VMAILBOX_ACK);
4044ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
4054ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	/* update stats */
4064ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	hw->mbx.stats.msgs_rx++;
4074ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
4084ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyckout_no_read:
4094ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return ret_val;
4104ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
4114ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
4124ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck/**
4134ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  e1000_init_mbx_params_pf - set initial values for pf mailbox
4144ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  @hw: pointer to the HW structure
4154ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *
4164ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck *  Initializes the hw->mbx struct to correct values for pf mailbox
4174ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck */
4184ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duycks32 igb_init_mbx_params_pf(struct e1000_hw *hw)
4194ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck{
4204ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	struct e1000_mbx_info *mbx = &hw->mbx;
4214ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
4226b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->timeout = 0;
4236b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->usec_delay = 0;
4246b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny
4256b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->size = E1000_VFMAILBOX_SIZE;
4266b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny
4276b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->ops.read = igb_read_mbx_pf;
4286b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->ops.write = igb_write_mbx_pf;
4296b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->ops.read_posted = igb_read_posted_mbx;
4306b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->ops.write_posted = igb_write_posted_mbx;
4316b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->ops.check_for_msg = igb_check_for_msg_pf;
4326b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->ops.check_for_ack = igb_check_for_ack_pf;
4336b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->ops.check_for_rst = igb_check_for_rst_pf;
4346b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny
4356b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->stats.msgs_tx = 0;
4366b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->stats.msgs_rx = 0;
4376b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->stats.reqs = 0;
4386b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->stats.acks = 0;
4396b78bb1d46cfae6502826ec31a6e9f7222ab3cb4Carolyn Wyborny	mbx->stats.rsts = 0;
4404ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
4414ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck	return 0;
4424ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck}
4434ae196dfd61d06b061c069edcdd7c73121e60a21Alexander Duyck
444