Loading drivers/net/ethernet/intel/igb/igb.h +3 −0 Original line number Diff line number Diff line Loading @@ -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]; Loading @@ -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 */ Loading drivers/net/ethernet/intel/igb/igb_main.c +147 −30 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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 */ 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; Loading Loading @@ -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 (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 (!adapter->vfs_allocated_count) return; if (adapter->vfs_allocated_count) { adapter->vf_data = kcalloc(adapter->vfs_allocated_count, sizeof(struct vf_data_storage), GFP_KERNEL); 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"); 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); if (pci_enable_sriov(pdev, adapter->vfs_allocated_count)) { /* 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; #endif /* CONFIG_PCI_IOV */ 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; } out: return; #endif /* CONFIG_PCI_IOV */ } /** * igb_init_hw_timer - Initialize hardware timer used with IEEE 1588 timestamp * @adapter: board private structure to initialize Loading Loading @@ -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; Loading drivers/net/ethernet/intel/igbvf/netdev.c +2 −2 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ 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; if (test_bit(vid, adapter->active_vlans)) __vlan_hwaccel_put_tag(skb, vid); } netif_receive_skb(skb); Loading drivers/net/ethernet/intel/ixgbe/ixgbe.h +2 −1 Original line number Diff line number Diff line Loading @@ -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; Loading drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c +2 −0 Original line number Diff line number Diff line Loading @@ -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, Loading Loading
drivers/net/ethernet/intel/igb/igb.h +3 −0 Original line number Diff line number Diff line Loading @@ -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]; Loading @@ -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 */ Loading
drivers/net/ethernet/intel/igb/igb_main.c +147 −30 Original line number Diff line number Diff line Loading @@ -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); Loading Loading @@ -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 */ 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; Loading Loading @@ -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 (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 (!adapter->vfs_allocated_count) return; if (adapter->vfs_allocated_count) { adapter->vf_data = kcalloc(adapter->vfs_allocated_count, sizeof(struct vf_data_storage), GFP_KERNEL); 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"); 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); if (pci_enable_sriov(pdev, adapter->vfs_allocated_count)) { /* 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; #endif /* CONFIG_PCI_IOV */ 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; } out: return; #endif /* CONFIG_PCI_IOV */ } /** * igb_init_hw_timer - Initialize hardware timer used with IEEE 1588 timestamp * @adapter: board private structure to initialize Loading Loading @@ -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; Loading
drivers/net/ethernet/intel/igbvf/netdev.c +2 −2 Original line number Diff line number Diff line Loading @@ -102,7 +102,7 @@ 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; if (test_bit(vid, adapter->active_vlans)) __vlan_hwaccel_put_tag(skb, vid); } netif_receive_skb(skb); Loading
drivers/net/ethernet/intel/ixgbe/ixgbe.h +2 −1 Original line number Diff line number Diff line Loading @@ -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; Loading
drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c +2 −0 Original line number Diff line number Diff line Loading @@ -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, Loading