#include "e1000_osdep.h"
#include "e1000_api.h"
void
e1000_pci_set_mwi(struct e1000_hw *hw)
{
uint16_t val = hw->bus.pci_cmd_word | CMD_MEM_WRT_INVALIDATE;
e1000_write_pci_cfg(hw, PCI_COMMAND_REGISTER, &val);
}
void
e1000_pci_clear_mwi(struct e1000_hw *hw)
{
uint16_t val = hw->bus.pci_cmd_word & ~CMD_MEM_WRT_INVALIDATE;
e1000_write_pci_cfg(hw, PCI_COMMAND_REGISTER, &val);
}
void
e1000_write_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
{
pci_config_put16(OS_DEP(hw)->cfg_handle, reg, *value);
}
void
e1000_read_pci_cfg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
{
*value =
pci_config_get16(OS_DEP(hw)->cfg_handle, reg);
}
int32_t
e1000_read_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
{
uint8_t pcie_id = PCI_CAP_ID_PCI_E;
uint16_t pcie_cap;
int32_t status;
status = pci_lcap_locate((OS_DEP(hw))->cfg_handle, pcie_id, &pcie_cap);
if (status == DDI_SUCCESS) {
*value = pci_config_get16(OS_DEP(hw)->cfg_handle,
(pcie_cap + reg));
}
return (status);
}
int32_t
e1000_write_pcie_cap_reg(struct e1000_hw *hw, uint32_t reg, uint16_t *value)
{
uint8_t pcie_id = PCI_CAP_ID_PCI_E;
uint16_t pcie_cap;
int32_t status;
status = pci_lcap_locate(OS_DEP(hw)->cfg_handle, pcie_id, &pcie_cap);
if (status == DDI_SUCCESS) {
pci_config_put16(OS_DEP(hw)->cfg_handle,
(off_t)(pcie_cap + reg), *value);
}
return (status);
}
void
e1000_rar_clear(struct e1000_hw *hw, uint32_t index)
{
uint32_t rar_high;
rar_high = ~E1000_RAH_AV;
E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((index << 1) + 1), rar_high);
E1000_WRITE_FLUSH(hw);
}
void
e1000_rar_set_vmdq(struct e1000_hw *hw, const uint8_t *addr, uint32_t index,
uint32_t vmdq_mode, uint8_t qsel)
{
uint32_t rar_low, rar_high;
rar_low = ((uint32_t)addr[0] | ((uint32_t)addr[1] << 8) |
((uint32_t)addr[2] << 16) | ((uint32_t)addr[3] << 24));
rar_high = ((uint32_t)addr[4] | ((uint32_t)addr[5] << 8));
rar_high |= E1000_RAH_AV;
switch (vmdq_mode) {
default:
case E1000_VMDQ_OFF:
break;
case E1000_VMDQ_MAC:
rar_high |= (qsel << 18);
break;
case E1000_VMDQ_MAC_RSS:
rar_high |= 1 << (18 + qsel);
break;
}
E1000_WRITE_REG_ARRAY(hw, E1000_RA, (index << 1), rar_low);
E1000_WRITE_REG_ARRAY(hw, E1000_RA, ((index << 1) + 1), rar_high);
E1000_WRITE_FLUSH(hw);
}