/******************************************************************************
Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
3. Neither the name of the Intel Corporation nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
/*$FreeBSD$*/
#include "e1000_api.h"
/**
* e1000_init_phy_params_vf - Inits PHY params
* @hw: pointer to the HW structure
*
* Doesn't do much - there's no PHY available to the VF.
**/
{
DEBUGFUNC("e1000_init_phy_params_vf");
return E1000_SUCCESS;
}
/**
* e1000_init_nvm_params_vf - Inits NVM params
* @hw: pointer to the HW structure
*
* Doesn't do much - there's no NVM available to the VF.
**/
{
DEBUGFUNC("e1000_init_nvm_params_vf");
return E1000_SUCCESS;
}
/**
* e1000_init_mac_params_vf - Inits MAC params
* @hw: pointer to the HW structure
**/
{
DEBUGFUNC("e1000_init_mac_params_vf");
/* Set media type */
/*
* Virtual functions don't care what they're media type is as they
* have no direct access to the PHY, or the media. That is handled
* by the physical function driver.
*/
/* No ASF features for the VF driver */
/* ARC subsystem not supported */
/* Disable adaptive IFS mode so the generic funcs don't do anything */
/* VF's have no MTA Registers - PF feature only */
/* VF's have no access to RAR entries */
/* Function pointers */
/* link setup */
/* reset */
/* hw initialization */
/* check for link */
/* link info */
/* multicast address update */
/* set mac address */
/* read mac address */
return E1000_SUCCESS;
}
/**
* e1000_init_function_pointers_vf - Inits function pointers
* @hw: pointer to the HW structure
**/
{
DEBUGFUNC("e1000_init_function_pointers_vf");
}
/**
* e1000_acquire_vf - Acquire rights to access PHY or NVM.
* @hw: pointer to the HW structure
*
* There is no PHY or NVM so we want all attempts to acquire these to fail.
* even want any SW to attempt to use them.
**/
{
return -E1000_ERR_PHY;
}
/**
* e1000_release_vf - Release PHY or NVM
* @hw: pointer to the HW structure
*
* There is no PHY or NVM so we want all attempts to acquire these to fail.
* even want any SW to attempt to use them.
**/
{
return;
}
/**
* e1000_setup_link_vf - Sets up link.
* @hw: pointer to the HW structure
*
* Virtual functions cannot change link.
**/
{
DEBUGFUNC("e1000_setup_link_vf");
return E1000_SUCCESS;
}
/**
* e1000_get_bus_info_pcie_vf - Gets the bus info.
* @hw: pointer to the HW structure
*
* Virtual functions are not really on their own bus.
**/
{
DEBUGFUNC("e1000_get_bus_info_pcie_vf");
/* Do not set type PCI-E because we don't want disable master to run */
return 0;
}
/**
* e1000_get_link_up_info_vf - Gets link info.
* @hw: pointer to the HW structure
* @speed: pointer to 16 bit value to store link speed.
* @duplex: pointer to 16 bit value to store duplex.
*
* Since we cannot read the PHY and get accurate link info, we must rely upon
* the status register's data which is often stale and inaccurate.
**/
{
DEBUGFUNC("e1000_get_link_up_info_vf");
if (status & E1000_STATUS_SPEED_1000) {
*speed = SPEED_1000;
DEBUGOUT("1000 Mbs, ");
} else if (status & E1000_STATUS_SPEED_100) {
DEBUGOUT("100 Mbs, ");
} else {
DEBUGOUT("10 Mbs, ");
}
if (status & E1000_STATUS_FD) {
*duplex = FULL_DUPLEX;
DEBUGOUT("Full Duplex\n");
} else {
*duplex = HALF_DUPLEX;
DEBUGOUT("Half Duplex\n");
}
return E1000_SUCCESS;
}
/**
* e1000_reset_hw_vf - Resets the HW
* @hw: pointer to the HW structure
*
* VF's provide a function level reset. This is done using bit 26 of ctrl_reg.
* This is all the reset we can perform on a VF.
**/
{
DEBUGFUNC("e1000_reset_hw_vf");
DEBUGOUT("Issuing a function level reset to MAC\n");
/* we cannot reset while the RSTI / RSTD bits are asserted */
timeout--;
usec_delay(5);
}
if (timeout) {
/* mailbox timeout can now become active */
msgbuf[0] = E1000_VF_RESET;
msec_delay(10);
/* set our "perm_addr" based on info provided by PF */
if (!ret_val) {
if (msgbuf[0] == (E1000_VF_RESET |
else
}
}
return ret_val;
}
/**
* e1000_init_hw_vf - Inits the HW
* @hw: pointer to the HW structure
*
* Not much to do here except clear the PF Reset indication if there is one.
**/
{
DEBUGFUNC("e1000_init_hw_vf");
/* attempt to set and restore our mac address */
return E1000_SUCCESS;
}
/**
* e1000_rar_set_vf - set device MAC address
* @hw: pointer to the HW structure
* @addr: pointer to the receive address
* @index receive address array register
**/
{
msgbuf[0] = E1000_VF_SET_MAC_ADDR;
if (!ret_val)
msgbuf[0] &= ~E1000_VT_MSGTYPE_CTS;
/* if nacked the address was rejected, use "perm_addr" */
if (!ret_val &&
return E1000_SUCCESS;
}
/**
* e1000_hash_mc_addr_vf - Generate a multicast hash value
* @hw: pointer to the HW structure
* @mc_addr: pointer to a multicast address
*
* Generates a multicast address hash value which is used to determine
* the multicast filter table array address and new table value.
**/
{
DEBUGFUNC("e1000_hash_mc_addr_generic");
/* Register count multiplied by bits per register */
/*
* The bit_shift is the number of left-shifts
* where 0xFF would still fall within the hash mask.
*/
bit_shift++;
return hash_value;
}
{
if (!retval)
}
/**
* e1000_update_mc_addr_list_vf - Update Multicast addresses
* @hw: pointer to the HW structure
* @mc_addr_list: array of multicast addresses to program
* @mc_addr_count: number of multicast addresses to program
*
* Updates the Multicast Table Array.
* The caller must have a packed mc_addr_list of multicast addresses.
**/
{
u32 i;
DEBUGFUNC("e1000_update_mc_addr_list_vf");
/* Each entry in the list uses 1 16 bit word. We have 30
* 16 bit words available in our HW msg buffer (minus 1 for the
* msg type). That's 30 hash values if we pack 'em right. If
* there are more than 30 MC addresses to add then punt the
* extras for now and then add code to handle more than 30 later.
* It would be unusual for a server to request that many multi-cast
* addresses except for in large enterprise network environments.
*/
if (mc_addr_count > 30) {
mc_addr_count = 30;
}
msgbuf[0] = E1000_VF_SET_MULTICAST;
for (i = 0; i < mc_addr_count; i++) {
}
}
/**
* @hw: pointer to the HW structure
* @set: if TRUE then set bit, else clear bit
**/
{
msgbuf[0] = E1000_VF_SET_VLAN;
/* Setting the 8 bit field MSG INFO to TRUE indicates "add" */
if (set)
msgbuf[0] |= E1000_VF_SET_VLAN_ADD;
}
/** e1000_rlpml_set_vf - Set the maximum receive packet length
* @hw: pointer to the HW structure
* @max_size: value to assign to max frame size
**/
{
msgbuf[0] = E1000_VF_SET_LPE;
}
/**
* e1000_promisc_set_vf - Set flags for Unicast or Multicast promisc
* @hw: pointer to the HW structure
* @uni: boolean indicating unicast promisc status
* @multi: boolean indicating multicast promisc status
**/
{
switch (type) {
case e1000_promisc_multicast:
break;
case e1000_promisc_enabled:
case e1000_promisc_unicast:
case e1000_promisc_disabled:
break;
default:
return -E1000_ERR_MAC_INIT;
}
if (!ret_val)
return ret_val;
}
/**
* e1000_read_mac_addr_vf - Read device MAC address
* @hw: pointer to the HW structure
**/
{
int i;
for (i = 0; i < ETH_ADDR_LEN; i++)
return E1000_SUCCESS;
}
/**
* e1000_check_for_link_vf - Check for link for a virtual interface
* @hw: pointer to the HW structure
*
* Checks to see if the underlying PF is still talking to the VF and
* if it is then it reports the link state to the hardware, otherwise
* it reports link down and returns an error.
**/
{
DEBUGFUNC("e1000_check_for_link_vf");
/*
* We only want to run this if there has been a rst asserted.
* in this case that could mean a link change, device reset,
* or a virtual function reset
*/
/* If we were hit with a reset or timeout drop the link */
if (!mac->get_link_status)
goto out;
/* if link status is down no point in checking to see if pf is up */
goto out;
/* if the read failed it could just be a mailbox collision, best wait
* until we are called again and don't report an error */
goto out;
/* if incoming message isn't clear to send we are waiting on response */
if (!(in_msg & E1000_VT_MSGTYPE_CTS)) {
/* message is not CTS and is NACK we have lost CTS status */
if (in_msg & E1000_VT_MSGTYPE_NACK)
goto out;
}
/* at this point we know the PF is talking to us, check and see if
* we are still accepting timeout or if we had a timeout failure.
* if we failed then we will need to reinit */
goto out;
}
/* if we passed all the tests above then the link is up and we no
* longer need to check for link */
out:
return ret_val;
}