Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next
Browse files Browse the repository at this point in the history
  • Loading branch information
davem330 committed Oct 18, 2011
2 parents 01b7806 + 15e5209 commit f7ba35d
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 50 deletions.
3 changes: 3 additions & 0 deletions drivers/net/ethernet/intel/igb/igb.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ struct igb_adapter;
#define IGB_MAX_VF_MC_ENTRIES 30
#define IGB_MAX_VF_FUNCTIONS 8
#define IGB_MAX_VFTA_ENTRIES 128
#define IGB_82576_VF_DEV_ID 0x10CA
#define IGB_I350_VF_DEV_ID 0x1520

struct vf_data_storage {
unsigned char vf_mac_addresses[ETH_ALEN];
Expand All @@ -83,6 +85,7 @@ struct vf_data_storage {
u16 pf_vlan; /* When set, guest VLAN config not allowed. */
u16 pf_qos;
u16 tx_rate;
struct pci_dev *vfdev;
};

#define IGB_VF_FLAG_CTS 0x00000001 /* VF is clear to send data */
Expand Down
177 changes: 147 additions & 30 deletions drivers/net/ethernet/intel/igb/igb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate);
static int igb_ndo_get_vf_config(struct net_device *netdev, int vf,
struct ifla_vf_info *ivi);
static void igb_check_vf_rate_limit(struct igb_adapter *);
static int igb_vf_configure(struct igb_adapter *adapter, int vf);
static int igb_find_enabled_vfs(struct igb_adapter *adapter);
static int igb_check_vf_assignment(struct igb_adapter *adapter);

#ifdef CONFIG_PM
static int igb_suspend(struct pci_dev *, pm_message_t);
Expand Down Expand Up @@ -2232,8 +2235,12 @@ static void __devexit igb_remove(struct pci_dev *pdev)
/* reclaim resources allocated to VFs */
if (adapter->vf_data) {
/* disable iov and allow time for transactions to clear */
pci_disable_sriov(pdev);
msleep(500);
if (!igb_check_vf_assignment(adapter)) {
pci_disable_sriov(pdev);
msleep(500);
} else {
dev_info(&pdev->dev, "VF(s) assigned to guests!\n");
}

kfree(adapter->vf_data);
adapter->vf_data = NULL;
Expand Down Expand Up @@ -2270,42 +2277,49 @@ static void __devinit igb_probe_vfs(struct igb_adapter * adapter)
{
#ifdef CONFIG_PCI_IOV
struct pci_dev *pdev = adapter->pdev;
int old_vfs = igb_find_enabled_vfs(adapter);
int i;

if (adapter->vfs_allocated_count) {
adapter->vf_data = kcalloc(adapter->vfs_allocated_count,
sizeof(struct vf_data_storage),
GFP_KERNEL);
/* if allocation failed then we do not support SR-IOV */
if (!adapter->vf_data) {
adapter->vfs_allocated_count = 0;
dev_err(&pdev->dev, "Unable to allocate memory for VF "
"Data Storage\n");
}
if (old_vfs) {
dev_info(&pdev->dev, "%d pre-allocated VFs found - override "
"max_vfs setting of %d\n", old_vfs, max_vfs);
adapter->vfs_allocated_count = old_vfs;
}

if (pci_enable_sriov(pdev, adapter->vfs_allocated_count)) {
kfree(adapter->vf_data);
adapter->vf_data = NULL;
#endif /* CONFIG_PCI_IOV */
if (!adapter->vfs_allocated_count)
return;

adapter->vf_data = kcalloc(adapter->vfs_allocated_count,
sizeof(struct vf_data_storage), GFP_KERNEL);
/* if allocation failed then we do not support SR-IOV */
if (!adapter->vf_data) {
adapter->vfs_allocated_count = 0;
#ifdef CONFIG_PCI_IOV
} else {
unsigned char mac_addr[ETH_ALEN];
int i;
dev_info(&pdev->dev, "%d vfs allocated\n",
adapter->vfs_allocated_count);
for (i = 0; i < adapter->vfs_allocated_count; i++) {
random_ether_addr(mac_addr);
igb_set_vf_mac(adapter, i, mac_addr);
}
/* DMA Coalescing is not supported in IOV mode. */
if (adapter->flags & IGB_FLAG_DMAC)
adapter->flags &= ~IGB_FLAG_DMAC;
dev_err(&pdev->dev, "Unable to allocate memory for VF "
"Data Storage\n");
goto out;
}

if (!old_vfs) {
if (pci_enable_sriov(pdev, adapter->vfs_allocated_count))
goto err_out;
}
dev_info(&pdev->dev, "%d VFs allocated\n",
adapter->vfs_allocated_count);
for (i = 0; i < adapter->vfs_allocated_count; i++)
igb_vf_configure(adapter, i);

/* DMA Coalescing is not supported in IOV mode. */
adapter->flags &= ~IGB_FLAG_DMAC;
goto out;
err_out:
kfree(adapter->vf_data);
adapter->vf_data = NULL;
adapter->vfs_allocated_count = 0;
out:
return;
#endif /* CONFIG_PCI_IOV */
}


/**
* igb_init_hw_timer - Initialize hardware timer used with IEEE 1588 timestamp
* @adapter: board private structure to initialize
Expand Down Expand Up @@ -4917,6 +4931,109 @@ static int igb_notify_dca(struct notifier_block *nb, unsigned long event,
}
#endif /* CONFIG_IGB_DCA */

#ifdef CONFIG_PCI_IOV
static int igb_vf_configure(struct igb_adapter *adapter, int vf)
{
unsigned char mac_addr[ETH_ALEN];
struct pci_dev *pdev = adapter->pdev;
struct e1000_hw *hw = &adapter->hw;
struct pci_dev *pvfdev;
unsigned int device_id;
u16 thisvf_devfn;

random_ether_addr(mac_addr);
igb_set_vf_mac(adapter, vf, mac_addr);

switch (adapter->hw.mac.type) {
case e1000_82576:
device_id = IGB_82576_VF_DEV_ID;
/* VF Stride for 82576 is 2 */
thisvf_devfn = (pdev->devfn + 0x80 + (vf << 1)) |
(pdev->devfn & 1);
break;
case e1000_i350:
device_id = IGB_I350_VF_DEV_ID;
/* VF Stride for I350 is 4 */
thisvf_devfn = (pdev->devfn + 0x80 + (vf << 2)) |
(pdev->devfn & 3);
break;
default:
device_id = 0;
thisvf_devfn = 0;
break;
}

pvfdev = pci_get_device(hw->vendor_id, device_id, NULL);
while (pvfdev) {
if (pvfdev->devfn == thisvf_devfn)
break;
pvfdev = pci_get_device(hw->vendor_id,
device_id, pvfdev);
}

if (pvfdev)
adapter->vf_data[vf].vfdev = pvfdev;
else
dev_err(&pdev->dev,
"Couldn't find pci dev ptr for VF %4.4x\n",
thisvf_devfn);
return pvfdev != NULL;
}

static int igb_find_enabled_vfs(struct igb_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
struct pci_dev *pdev = adapter->pdev;
struct pci_dev *pvfdev;
u16 vf_devfn = 0;
u16 vf_stride;
unsigned int device_id;
int vfs_found = 0;

switch (adapter->hw.mac.type) {
case e1000_82576:
device_id = IGB_82576_VF_DEV_ID;
/* VF Stride for 82576 is 2 */
vf_stride = 2;
break;
case e1000_i350:
device_id = IGB_I350_VF_DEV_ID;
/* VF Stride for I350 is 4 */
vf_stride = 4;
break;
default:
device_id = 0;
vf_stride = 0;
break;
}

vf_devfn = pdev->devfn + 0x80;
pvfdev = pci_get_device(hw->vendor_id, device_id, NULL);
while (pvfdev) {
if (pvfdev->devfn == vf_devfn)
vfs_found++;
vf_devfn += vf_stride;
pvfdev = pci_get_device(hw->vendor_id,
device_id, pvfdev);
}

return vfs_found;
}

static int igb_check_vf_assignment(struct igb_adapter *adapter)
{
int i;
for (i = 0; i < adapter->vfs_allocated_count; i++) {
if (adapter->vf_data[i].vfdev) {
if (adapter->vf_data[i].vfdev->dev_flags &
PCI_DEV_FLAGS_ASSIGNED)
return true;
}
}
return false;
}

#endif
static void igb_ping_all_vfs(struct igb_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/intel/igbvf/netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ static void igbvf_receive_skb(struct igbvf_adapter *adapter,
{
if (status & E1000_RXD_STAT_VP) {
u16 vid = le16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK;

__vlan_hwaccel_put_tag(skb, vid);
if (test_bit(vid, adapter->active_vlans))
__vlan_hwaccel_put_tag(skb, vid);
}
netif_receive_skb(skb);
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/ethernet/intel/ixgbe/ixgbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ struct ixgbe_adapter {
u64 rsc_total_count;
u64 rsc_total_flush;
u32 wol;
u16 eeprom_version;
u16 eeprom_verh;
u16 eeprom_verl;
u16 eeprom_cap;

int node;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,8 @@ static struct ixgbe_mac_operations mac_ops_82598 = {
static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
.init_params = &ixgbe_init_eeprom_params_generic,
.read = &ixgbe_read_eerd_generic,
.write = &ixgbe_write_eeprom_generic,
.write_buffer = &ixgbe_write_eeprom_buffer_bit_bang_generic,
.read_buffer = &ixgbe_read_eerd_buffer_generic,
.calc_checksum = &ixgbe_calc_eeprom_checksum_generic,
.validate_checksum = &ixgbe_validate_eeprom_checksum_generic,
Expand Down
16 changes: 8 additions & 8 deletions drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -3341,7 +3341,7 @@ static u8 ixgbe_calculate_checksum(u8 *buffer, u32 length)
* Communicates with the manageability block. On success return 0
* else return IXGBE_ERR_HOST_INTERFACE_COMMAND.
**/
static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u8 *buffer,
static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
u32 length)
{
u32 hicr, i;
Expand Down Expand Up @@ -3374,7 +3374,7 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u8 *buffer,
*/
for (i = 0; i < dword_len; i++)
IXGBE_WRITE_REG_ARRAY(hw, IXGBE_FLEX_MNG,
i, *((u32 *)buffer + i));
i, cpu_to_le32(buffer[i]));

/* Setting this bit tells the ARC that a new command is pending. */
IXGBE_WRITE_REG(hw, IXGBE_HICR, hicr | IXGBE_HICR_C);
Expand All @@ -3398,9 +3398,10 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u8 *buffer,
dword_len = hdr_size >> 2;

/* first pull in the header so we know the buffer length */
for (i = 0; i < dword_len; i++)
*((u32 *)buffer + i) =
IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, i);
for (i = 0; i < dword_len; i++) {
buffer[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, i);
le32_to_cpus(&buffer[i]);
}

/* If there is any thing in data position pull it in */
buf_len = ((struct ixgbe_hic_hdr *)buffer)->buf_len;
Expand All @@ -3418,8 +3419,7 @@ static s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u8 *buffer,

/* Pull in the rest of the buffer (i is where we left off)*/
for (; i < buf_len; i++)
*((u32 *)buffer + i) =
IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, i);
buffer[i] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, i);

out:
return ret_val;
Expand Down Expand Up @@ -3465,7 +3465,7 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 maj, u8 min,
fw_cmd.pad2 = 0;

for (i = 0; i <= FW_CEM_MAX_RETRIES; i++) {
ret_val = ixgbe_host_interface_command(hw, (u8 *)&fw_cmd,
ret_val = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
sizeof(fw_cmd));
if (ret_val != 0)
continue;
Expand Down
Loading

0 comments on commit f7ba35d

Please sign in to comment.