aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Rose <gregory.v.rose@intel.com>2011-09-29 01:57:33 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2011-10-16 16:15:48 -0400
commitde4c7f653b2ff24dfff47edea0d67aa6fc681cee (patch)
tree06f93c37d78856e1f1e465c0d448d2def3b56596
parent5f8444a3fa617076f8da51a3e8ecce01a5d7f738 (diff)
ixgbe: Add new netdev op to turn spoof checking on or off per VF
Implements the new netdev op to allow user configuration of spoof checking on a per VF basis. V2 - Change netdev spoof check op setting to bool Signed-off-by: Greg Rose <gregory.v.rose@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe.h3
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c10
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c48
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h1
4 files changed, 52 insertions, 10 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index c1f76aaf8774..6c4d693be08d 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -130,6 +130,8 @@ struct vf_data_storage {
130 u16 pf_vlan; /* When set, guest VLAN config not allowed. */ 130 u16 pf_vlan; /* When set, guest VLAN config not allowed. */
131 u16 pf_qos; 131 u16 pf_qos;
132 u16 tx_rate; 132 u16 tx_rate;
133 u16 vlan_count;
134 u8 spoofchk_enabled;
133 struct pci_dev *vfdev; 135 struct pci_dev *vfdev;
134}; 136};
135 137
@@ -509,7 +511,6 @@ struct ixgbe_adapter {
509 int vf_rate_link_speed; 511 int vf_rate_link_speed;
510 struct vf_macvlans vf_mvs; 512 struct vf_macvlans vf_mvs;
511 struct vf_macvlans *mv_list; 513 struct vf_macvlans *mv_list;
512 bool antispoofing_enabled;
513 514
514 struct hlist_head fdir_filter_list; 515 struct hlist_head fdir_filter_list;
515 union ixgbe_atr_input fdir_mask; 516 union ixgbe_atr_input fdir_mask;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index f740a8eadf7c..fb7d8842a362 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -2816,6 +2816,7 @@ static void ixgbe_configure_virtualization(struct ixgbe_adapter *adapter)
2816 u32 vt_reg_bits; 2816 u32 vt_reg_bits;
2817 u32 reg_offset, vf_shift; 2817 u32 reg_offset, vf_shift;
2818 u32 vmdctl; 2818 u32 vmdctl;
2819 int i;
2819 2820
2820 if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) 2821 if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
2821 return; 2822 return;
@@ -2851,9 +2852,13 @@ static void ixgbe_configure_virtualization(struct ixgbe_adapter *adapter)
2851 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN); 2852 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
2852 /* Enable MAC Anti-Spoofing */ 2853 /* Enable MAC Anti-Spoofing */
2853 hw->mac.ops.set_mac_anti_spoofing(hw, 2854 hw->mac.ops.set_mac_anti_spoofing(hw,
2854 (adapter->antispoofing_enabled = 2855 (adapter->num_vfs != 0),
2855 (adapter->num_vfs != 0)),
2856 adapter->num_vfs); 2856 adapter->num_vfs);
2857 /* For VFs that have spoof checking turned off */
2858 for (i = 0; i < adapter->num_vfs; i++) {
2859 if (!adapter->vfinfo[i].spoofchk_enabled)
2860 ixgbe_ndo_set_vf_spoofchk(adapter->netdev, i, false);
2861 }
2857} 2862}
2858 2863
2859static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) 2864static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter)
@@ -7277,6 +7282,7 @@ static const struct net_device_ops ixgbe_netdev_ops = {
7277 .ndo_set_vf_mac = ixgbe_ndo_set_vf_mac, 7282 .ndo_set_vf_mac = ixgbe_ndo_set_vf_mac,
7278 .ndo_set_vf_vlan = ixgbe_ndo_set_vf_vlan, 7283 .ndo_set_vf_vlan = ixgbe_ndo_set_vf_vlan,
7279 .ndo_set_vf_tx_rate = ixgbe_ndo_set_vf_bw, 7284 .ndo_set_vf_tx_rate = ixgbe_ndo_set_vf_bw,
7285 .ndo_set_vf_spoofchk = ixgbe_ndo_set_vf_spoofchk,
7280 .ndo_get_vf_config = ixgbe_ndo_get_vf_config, 7286 .ndo_get_vf_config = ixgbe_ndo_get_vf_config,
7281 .ndo_get_stats64 = ixgbe_get_stats64, 7287 .ndo_get_stats64 = ixgbe_get_stats64,
7282 .ndo_setup_tc = ixgbe_setup_tc, 7288 .ndo_setup_tc = ixgbe_setup_tc,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index 468ddd0873da..db95731863d7 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -151,6 +151,8 @@ void ixgbe_enable_sriov(struct ixgbe_adapter *adapter,
151 /* Disable RSC when in SR-IOV mode */ 151 /* Disable RSC when in SR-IOV mode */
152 adapter->flags2 &= ~(IXGBE_FLAG2_RSC_CAPABLE | 152 adapter->flags2 &= ~(IXGBE_FLAG2_RSC_CAPABLE |
153 IXGBE_FLAG2_RSC_ENABLED); 153 IXGBE_FLAG2_RSC_ENABLED);
154 for (i = 0; i < adapter->num_vfs; i++)
155 adapter->vfinfo[i].spoofchk_enabled = true;
154 return; 156 return;
155 } 157 }
156 158
@@ -620,7 +622,13 @@ static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf)
620 vf); 622 vf);
621 retval = -1; 623 retval = -1;
622 } else { 624 } else {
625 if (add)
626 adapter->vfinfo[vf].vlan_count++;
627 else if (adapter->vfinfo[vf].vlan_count)
628 adapter->vfinfo[vf].vlan_count--;
623 retval = ixgbe_set_vf_vlan(adapter, add, vid, vf); 629 retval = ixgbe_set_vf_vlan(adapter, add, vid, vf);
630 if (!retval && adapter->vfinfo[vf].spoofchk_enabled)
631 hw->mac.ops.set_vlan_anti_spoofing(hw, true, vf);
624 } 632 }
625 break; 633 break;
626 case IXGBE_VF_SET_MACVLAN: 634 case IXGBE_VF_SET_MACVLAN:
@@ -632,12 +640,8 @@ static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf)
632 * greater than 0 will indicate the VF is setting a 640 * greater than 0 will indicate the VF is setting a
633 * macvlan MAC filter. 641 * macvlan MAC filter.
634 */ 642 */
635 if (index > 0 && adapter->antispoofing_enabled) { 643 if (index > 0 && adapter->vfinfo[vf].spoofchk_enabled)
636 hw->mac.ops.set_mac_anti_spoofing(hw, false, 644 ixgbe_ndo_set_vf_spoofchk(adapter->netdev, vf, false);
637 adapter->num_vfs);
638 hw->mac.ops.set_vlan_anti_spoofing(hw, false, vf);
639 adapter->antispoofing_enabled = false;
640 }
641 retval = ixgbe_set_vf_macvlan(adapter, vf, index, 645 retval = ixgbe_set_vf_macvlan(adapter, vf, index,
642 (unsigned char *)(&msgbuf[1])); 646 (unsigned char *)(&msgbuf[1]));
643 break; 647 break;
@@ -748,8 +752,9 @@ int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos)
748 goto out; 752 goto out;
749 ixgbe_set_vmvir(adapter, vlan | (qos << VLAN_PRIO_SHIFT), vf); 753 ixgbe_set_vmvir(adapter, vlan | (qos << VLAN_PRIO_SHIFT), vf);
750 ixgbe_set_vmolr(hw, vf, false); 754 ixgbe_set_vmolr(hw, vf, false);
751 if (adapter->antispoofing_enabled) 755 if (adapter->vfinfo[vf].spoofchk_enabled)
752 hw->mac.ops.set_vlan_anti_spoofing(hw, true, vf); 756 hw->mac.ops.set_vlan_anti_spoofing(hw, true, vf);
757 adapter->vfinfo[vf].vlan_count++;
753 adapter->vfinfo[vf].pf_vlan = vlan; 758 adapter->vfinfo[vf].pf_vlan = vlan;
754 adapter->vfinfo[vf].pf_qos = qos; 759 adapter->vfinfo[vf].pf_qos = qos;
755 dev_info(&adapter->pdev->dev, 760 dev_info(&adapter->pdev->dev,
@@ -768,6 +773,8 @@ int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos)
768 ixgbe_set_vmvir(adapter, vlan, vf); 773 ixgbe_set_vmvir(adapter, vlan, vf);
769 ixgbe_set_vmolr(hw, vf, true); 774 ixgbe_set_vmolr(hw, vf, true);
770 hw->mac.ops.set_vlan_anti_spoofing(hw, false, vf); 775 hw->mac.ops.set_vlan_anti_spoofing(hw, false, vf);
776 if (adapter->vfinfo[vf].vlan_count)
777 adapter->vfinfo[vf].vlan_count--;
771 adapter->vfinfo[vf].pf_vlan = 0; 778 adapter->vfinfo[vf].pf_vlan = 0;
772 adapter->vfinfo[vf].pf_qos = 0; 779 adapter->vfinfo[vf].pf_qos = 0;
773 } 780 }
@@ -877,6 +884,32 @@ int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
877 return 0; 884 return 0;
878} 885}
879 886
887int ixgbe_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting)
888{
889 struct ixgbe_adapter *adapter = netdev_priv(netdev);
890 int vf_target_reg = vf >> 3;
891 int vf_target_shift = vf % 8;
892 struct ixgbe_hw *hw = &adapter->hw;
893 u32 regval;
894
895 adapter->vfinfo[vf].spoofchk_enabled = setting;
896
897 regval = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
898 regval &= ~(1 << vf_target_shift);
899 regval |= (setting << vf_target_shift);
900 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), regval);
901
902 if (adapter->vfinfo[vf].vlan_count) {
903 vf_target_shift += IXGBE_SPOOF_VLANAS_SHIFT;
904 regval = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
905 regval &= ~(1 << vf_target_shift);
906 regval |= (setting << vf_target_shift);
907 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), regval);
908 }
909
910 return 0;
911}
912
880int ixgbe_ndo_get_vf_config(struct net_device *netdev, 913int ixgbe_ndo_get_vf_config(struct net_device *netdev,
881 int vf, struct ifla_vf_info *ivi) 914 int vf, struct ifla_vf_info *ivi)
882{ 915{
@@ -888,5 +921,6 @@ int ixgbe_ndo_get_vf_config(struct net_device *netdev,
888 ivi->tx_rate = adapter->vfinfo[vf].tx_rate; 921 ivi->tx_rate = adapter->vfinfo[vf].tx_rate;
889 ivi->vlan = adapter->vfinfo[vf].pf_vlan; 922 ivi->vlan = adapter->vfinfo[vf].pf_vlan;
890 ivi->qos = adapter->vfinfo[vf].pf_qos; 923 ivi->qos = adapter->vfinfo[vf].pf_qos;
924 ivi->spoofchk = adapter->vfinfo[vf].spoofchk_enabled;
891 return 0; 925 return 0;
892} 926}
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h
index 278184757b69..5a7e1eb33599 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h
@@ -38,6 +38,7 @@ int ixgbe_ndo_set_vf_mac(struct net_device *netdev, int queue, u8 *mac);
38int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int queue, u16 vlan, 38int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int queue, u16 vlan,
39 u8 qos); 39 u8 qos);
40int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate); 40int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate);
41int ixgbe_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting);
41int ixgbe_ndo_get_vf_config(struct net_device *netdev, 42int ixgbe_ndo_get_vf_config(struct net_device *netdev,
42 int vf, struct ifla_vf_info *ivi); 43 int vf, struct ifla_vf_info *ivi);
43void ixgbe_check_vf_rate_limit(struct ixgbe_adapter *adapter); 44void ixgbe_check_vf_rate_limit(struct ixgbe_adapter *adapter);