diff options
author | Lior Levy <lior.levy@intel.com> | 2013-03-03 15:27:48 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2013-04-18 19:40:32 -0400 |
commit | 70ea47832521e6c0f053b4906484a7a34fbf0e5d (patch) | |
tree | 4d01bdd3cae5d7738def37104288efa5bcb58694 | |
parent | 87371b9de5becc32af2f9be84008b8a8a424c58a (diff) |
igb: add support for spoofchk config
Add support for spoofchk configuration per VF via iproute2 tool.
Signed-off-by: Lior Levy <lior.levy@intel.com>
Tested-by: Sibai Li <sibai.li@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r-- | drivers/net/ethernet/intel/igb/igb.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/igb/igb_main.c | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h index cef8ec114bd8..d47ac2ae1b41 100644 --- a/drivers/net/ethernet/intel/igb/igb.h +++ b/drivers/net/ethernet/intel/igb/igb.h | |||
@@ -103,6 +103,7 @@ struct vf_data_storage { | |||
103 | u16 pf_vlan; /* When set, guest VLAN config not allowed. */ | 103 | u16 pf_vlan; /* When set, guest VLAN config not allowed. */ |
104 | u16 pf_qos; | 104 | u16 pf_qos; |
105 | u16 tx_rate; | 105 | u16 tx_rate; |
106 | bool spoofchk_enabled; | ||
106 | }; | 107 | }; |
107 | 108 | ||
108 | #define IGB_VF_FLAG_CTS 0x00000001 /* VF is clear to send data */ | 109 | #define IGB_VF_FLAG_CTS 0x00000001 /* VF is clear to send data */ |
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index c54ba4224ac6..666f87c4bfa3 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c | |||
@@ -169,6 +169,8 @@ static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac); | |||
169 | static int igb_ndo_set_vf_vlan(struct net_device *netdev, | 169 | static int igb_ndo_set_vf_vlan(struct net_device *netdev, |
170 | int vf, u16 vlan, u8 qos); | 170 | int vf, u16 vlan, u8 qos); |
171 | static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate); | 171 | static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate); |
172 | static int igb_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, | ||
173 | bool setting); | ||
172 | static int igb_ndo_get_vf_config(struct net_device *netdev, int vf, | 174 | static int igb_ndo_get_vf_config(struct net_device *netdev, int vf, |
173 | struct ifla_vf_info *ivi); | 175 | struct ifla_vf_info *ivi); |
174 | static void igb_check_vf_rate_limit(struct igb_adapter *); | 176 | static void igb_check_vf_rate_limit(struct igb_adapter *); |
@@ -1896,6 +1898,7 @@ static const struct net_device_ops igb_netdev_ops = { | |||
1896 | .ndo_set_vf_mac = igb_ndo_set_vf_mac, | 1898 | .ndo_set_vf_mac = igb_ndo_set_vf_mac, |
1897 | .ndo_set_vf_vlan = igb_ndo_set_vf_vlan, | 1899 | .ndo_set_vf_vlan = igb_ndo_set_vf_vlan, |
1898 | .ndo_set_vf_tx_rate = igb_ndo_set_vf_bw, | 1900 | .ndo_set_vf_tx_rate = igb_ndo_set_vf_bw, |
1901 | .ndo_set_vf_spoofchk = igb_ndo_set_vf_spoofchk, | ||
1899 | .ndo_get_vf_config = igb_ndo_get_vf_config, | 1902 | .ndo_get_vf_config = igb_ndo_get_vf_config, |
1900 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1903 | #ifdef CONFIG_NET_POLL_CONTROLLER |
1901 | .ndo_poll_controller = igb_netpoll, | 1904 | .ndo_poll_controller = igb_netpoll, |
@@ -5230,6 +5233,9 @@ static int igb_vf_configure(struct igb_adapter *adapter, int vf) | |||
5230 | eth_zero_addr(mac_addr); | 5233 | eth_zero_addr(mac_addr); |
5231 | igb_set_vf_mac(adapter, vf, mac_addr); | 5234 | igb_set_vf_mac(adapter, vf, mac_addr); |
5232 | 5235 | ||
5236 | /* By default spoof check is enabled for all VFs */ | ||
5237 | adapter->vf_data[vf].spoofchk_enabled = true; | ||
5238 | |||
5233 | return 0; | 5239 | return 0; |
5234 | } | 5240 | } |
5235 | 5241 | ||
@@ -7592,6 +7598,33 @@ static int igb_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate) | |||
7592 | return 0; | 7598 | return 0; |
7593 | } | 7599 | } |
7594 | 7600 | ||
7601 | static int igb_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, | ||
7602 | bool setting) | ||
7603 | { | ||
7604 | struct igb_adapter *adapter = netdev_priv(netdev); | ||
7605 | struct e1000_hw *hw = &adapter->hw; | ||
7606 | u32 reg_val, reg_offset; | ||
7607 | |||
7608 | if (!adapter->vfs_allocated_count) | ||
7609 | return -EOPNOTSUPP; | ||
7610 | |||
7611 | if (vf >= adapter->vfs_allocated_count) | ||
7612 | return -EINVAL; | ||
7613 | |||
7614 | reg_offset = (hw->mac.type == e1000_82576) ? E1000_DTXSWC : E1000_TXSWC; | ||
7615 | reg_val = rd32(reg_offset); | ||
7616 | if (setting) | ||
7617 | reg_val |= ((1 << vf) | | ||
7618 | (1 << (vf + E1000_DTXSWC_VLAN_SPOOF_SHIFT))); | ||
7619 | else | ||
7620 | reg_val &= ~((1 << vf) | | ||
7621 | (1 << (vf + E1000_DTXSWC_VLAN_SPOOF_SHIFT))); | ||
7622 | wr32(reg_offset, reg_val); | ||
7623 | |||
7624 | adapter->vf_data[vf].spoofchk_enabled = setting; | ||
7625 | return E1000_SUCCESS; | ||
7626 | } | ||
7627 | |||
7595 | static int igb_ndo_get_vf_config(struct net_device *netdev, | 7628 | static int igb_ndo_get_vf_config(struct net_device *netdev, |
7596 | int vf, struct ifla_vf_info *ivi) | 7629 | int vf, struct ifla_vf_info *ivi) |
7597 | { | 7630 | { |
@@ -7603,6 +7636,7 @@ static int igb_ndo_get_vf_config(struct net_device *netdev, | |||
7603 | ivi->tx_rate = adapter->vf_data[vf].tx_rate; | 7636 | ivi->tx_rate = adapter->vf_data[vf].tx_rate; |
7604 | ivi->vlan = adapter->vf_data[vf].pf_vlan; | 7637 | ivi->vlan = adapter->vf_data[vf].pf_vlan; |
7605 | ivi->qos = adapter->vf_data[vf].pf_qos; | 7638 | ivi->qos = adapter->vf_data[vf].pf_qos; |
7639 | ivi->spoofchk = adapter->vf_data[vf].spoofchk_enabled; | ||
7606 | return 0; | 7640 | return 0; |
7607 | } | 7641 | } |
7608 | 7642 | ||