diff options
author | Jiri Pirko <jpirko@redhat.com> | 2011-07-20 23:27:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-07-21 16:47:57 -0400 |
commit | b2cb09b1a7725408a3464b2f593ceb222eff1042 (patch) | |
tree | c27d1f76af4d6b91a3783ddff6246bb2eb0669dd /drivers/net/igb | |
parent | 3326c784c9f492e988617d93f647ae0cfd4c8d09 (diff) |
igb: do vlan cleanup
- unify vlan and nonvlan rx path
- kill adapter->vlgrp and igb_vlan_rx_register
- allow to turn on/off rx/tx vlan accel via ethtool (set_features)
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/igb')
-rw-r--r-- | drivers/net/igb/igb.h | 4 | ||||
-rw-r--r-- | drivers/net/igb/igb_main.c | 90 |
2 files changed, 47 insertions, 47 deletions
diff --git a/drivers/net/igb/igb.h b/drivers/net/igb/igb.h index 0389ff6ea696..265e151b66c4 100644 --- a/drivers/net/igb/igb.h +++ b/drivers/net/igb/igb.h | |||
@@ -37,6 +37,8 @@ | |||
37 | #include <linux/clocksource.h> | 37 | #include <linux/clocksource.h> |
38 | #include <linux/timecompare.h> | 38 | #include <linux/timecompare.h> |
39 | #include <linux/net_tstamp.h> | 39 | #include <linux/net_tstamp.h> |
40 | #include <linux/bitops.h> | ||
41 | #include <linux/if_vlan.h> | ||
40 | 42 | ||
41 | struct igb_adapter; | 43 | struct igb_adapter; |
42 | 44 | ||
@@ -252,7 +254,7 @@ static inline int igb_desc_unused(struct igb_ring *ring) | |||
252 | struct igb_adapter { | 254 | struct igb_adapter { |
253 | struct timer_list watchdog_timer; | 255 | struct timer_list watchdog_timer; |
254 | struct timer_list phy_info_timer; | 256 | struct timer_list phy_info_timer; |
255 | struct vlan_group *vlgrp; | 257 | unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; |
256 | u16 mng_vlan_id; | 258 | u16 mng_vlan_id; |
257 | u32 bd_number; | 259 | u32 bd_number; |
258 | u32 wol; | 260 | u32 wol; |
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index f4d82b2859da..cb8c6bbbf0d2 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/types.h> | 29 | #include <linux/types.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/bitops.h> | ||
31 | #include <linux/vmalloc.h> | 32 | #include <linux/vmalloc.h> |
32 | #include <linux/pagemap.h> | 33 | #include <linux/pagemap.h> |
33 | #include <linux/netdevice.h> | 34 | #include <linux/netdevice.h> |
@@ -46,6 +47,7 @@ | |||
46 | #include <linux/if_ether.h> | 47 | #include <linux/if_ether.h> |
47 | #include <linux/aer.h> | 48 | #include <linux/aer.h> |
48 | #include <linux/prefetch.h> | 49 | #include <linux/prefetch.h> |
50 | #include <linux/if_vlan.h> | ||
49 | #ifdef CONFIG_IGB_DCA | 51 | #ifdef CONFIG_IGB_DCA |
50 | #include <linux/dca.h> | 52 | #include <linux/dca.h> |
51 | #endif | 53 | #endif |
@@ -140,7 +142,7 @@ static bool igb_clean_rx_irq_adv(struct igb_q_vector *, int *, int); | |||
140 | static int igb_ioctl(struct net_device *, struct ifreq *, int cmd); | 142 | static int igb_ioctl(struct net_device *, struct ifreq *, int cmd); |
141 | static void igb_tx_timeout(struct net_device *); | 143 | static void igb_tx_timeout(struct net_device *); |
142 | static void igb_reset_task(struct work_struct *); | 144 | static void igb_reset_task(struct work_struct *); |
143 | static void igb_vlan_rx_register(struct net_device *, struct vlan_group *); | 145 | static void igb_vlan_mode(struct net_device *netdev, u32 features); |
144 | static void igb_vlan_rx_add_vid(struct net_device *, u16); | 146 | static void igb_vlan_rx_add_vid(struct net_device *, u16); |
145 | static void igb_vlan_rx_kill_vid(struct net_device *, u16); | 147 | static void igb_vlan_rx_kill_vid(struct net_device *, u16); |
146 | static void igb_restore_vlan(struct igb_adapter *); | 148 | static void igb_restore_vlan(struct igb_adapter *); |
@@ -1362,7 +1364,7 @@ static void igb_update_mng_vlan(struct igb_adapter *adapter) | |||
1362 | 1364 | ||
1363 | if ((old_vid != (u16)IGB_MNG_VLAN_NONE) && | 1365 | if ((old_vid != (u16)IGB_MNG_VLAN_NONE) && |
1364 | (vid != old_vid) && | 1366 | (vid != old_vid) && |
1365 | !vlan_group_get_device(adapter->vlgrp, old_vid)) { | 1367 | !test_bit(old_vid, adapter->active_vlans)) { |
1366 | /* remove VID from filter table */ | 1368 | /* remove VID from filter table */ |
1367 | igb_vfta_set(hw, old_vid, false); | 1369 | igb_vfta_set(hw, old_vid, false); |
1368 | } | 1370 | } |
@@ -1748,10 +1750,25 @@ void igb_reset(struct igb_adapter *adapter) | |||
1748 | igb_get_phy_info(hw); | 1750 | igb_get_phy_info(hw); |
1749 | } | 1751 | } |
1750 | 1752 | ||
1753 | static u32 igb_fix_features(struct net_device *netdev, u32 features) | ||
1754 | { | ||
1755 | /* | ||
1756 | * Since there is no support for separate rx/tx vlan accel | ||
1757 | * enable/disable make sure tx flag is always in same state as rx. | ||
1758 | */ | ||
1759 | if (features & NETIF_F_HW_VLAN_RX) | ||
1760 | features |= NETIF_F_HW_VLAN_TX; | ||
1761 | else | ||
1762 | features &= ~NETIF_F_HW_VLAN_TX; | ||
1763 | |||
1764 | return features; | ||
1765 | } | ||
1766 | |||
1751 | static int igb_set_features(struct net_device *netdev, u32 features) | 1767 | static int igb_set_features(struct net_device *netdev, u32 features) |
1752 | { | 1768 | { |
1753 | struct igb_adapter *adapter = netdev_priv(netdev); | 1769 | struct igb_adapter *adapter = netdev_priv(netdev); |
1754 | int i; | 1770 | int i; |
1771 | u32 changed = netdev->features ^ features; | ||
1755 | 1772 | ||
1756 | for (i = 0; i < adapter->num_rx_queues; i++) { | 1773 | for (i = 0; i < adapter->num_rx_queues; i++) { |
1757 | if (features & NETIF_F_RXCSUM) | 1774 | if (features & NETIF_F_RXCSUM) |
@@ -1760,6 +1777,9 @@ static int igb_set_features(struct net_device *netdev, u32 features) | |||
1760 | adapter->rx_ring[i]->flags &= ~IGB_RING_FLAG_RX_CSUM; | 1777 | adapter->rx_ring[i]->flags &= ~IGB_RING_FLAG_RX_CSUM; |
1761 | } | 1778 | } |
1762 | 1779 | ||
1780 | if (changed & NETIF_F_HW_VLAN_RX) | ||
1781 | igb_vlan_mode(netdev, features); | ||
1782 | |||
1763 | return 0; | 1783 | return 0; |
1764 | } | 1784 | } |
1765 | 1785 | ||
@@ -1775,7 +1795,6 @@ static const struct net_device_ops igb_netdev_ops = { | |||
1775 | .ndo_do_ioctl = igb_ioctl, | 1795 | .ndo_do_ioctl = igb_ioctl, |
1776 | .ndo_tx_timeout = igb_tx_timeout, | 1796 | .ndo_tx_timeout = igb_tx_timeout, |
1777 | .ndo_validate_addr = eth_validate_addr, | 1797 | .ndo_validate_addr = eth_validate_addr, |
1778 | .ndo_vlan_rx_register = igb_vlan_rx_register, | ||
1779 | .ndo_vlan_rx_add_vid = igb_vlan_rx_add_vid, | 1798 | .ndo_vlan_rx_add_vid = igb_vlan_rx_add_vid, |
1780 | .ndo_vlan_rx_kill_vid = igb_vlan_rx_kill_vid, | 1799 | .ndo_vlan_rx_kill_vid = igb_vlan_rx_kill_vid, |
1781 | .ndo_set_vf_mac = igb_ndo_set_vf_mac, | 1800 | .ndo_set_vf_mac = igb_ndo_set_vf_mac, |
@@ -1785,7 +1804,8 @@ static const struct net_device_ops igb_netdev_ops = { | |||
1785 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1804 | #ifdef CONFIG_NET_POLL_CONTROLLER |
1786 | .ndo_poll_controller = igb_netpoll, | 1805 | .ndo_poll_controller = igb_netpoll, |
1787 | #endif | 1806 | #endif |
1788 | .ndo_set_features = igb_set_features, | 1807 | .ndo_fix_features = igb_fix_features, |
1808 | .ndo_set_features = igb_set_features, | ||
1789 | }; | 1809 | }; |
1790 | 1810 | ||
1791 | /** | 1811 | /** |
@@ -1930,11 +1950,11 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
1930 | NETIF_F_IPV6_CSUM | | 1950 | NETIF_F_IPV6_CSUM | |
1931 | NETIF_F_TSO | | 1951 | NETIF_F_TSO | |
1932 | NETIF_F_TSO6 | | 1952 | NETIF_F_TSO6 | |
1933 | NETIF_F_RXCSUM; | 1953 | NETIF_F_RXCSUM | |
1954 | NETIF_F_HW_VLAN_RX; | ||
1934 | 1955 | ||
1935 | netdev->features = netdev->hw_features | | 1956 | netdev->features = netdev->hw_features | |
1936 | NETIF_F_HW_VLAN_TX | | 1957 | NETIF_F_HW_VLAN_TX | |
1937 | NETIF_F_HW_VLAN_RX | | ||
1938 | NETIF_F_HW_VLAN_FILTER; | 1958 | NETIF_F_HW_VLAN_FILTER; |
1939 | 1959 | ||
1940 | netdev->vlan_features |= NETIF_F_TSO; | 1960 | netdev->vlan_features |= NETIF_F_TSO; |
@@ -2057,6 +2077,8 @@ static int __devinit igb_probe(struct pci_dev *pdev, | |||
2057 | if (err) | 2077 | if (err) |
2058 | goto err_register; | 2078 | goto err_register; |
2059 | 2079 | ||
2080 | igb_vlan_mode(netdev, netdev->features); | ||
2081 | |||
2060 | /* carrier off reporting is important to ethtool even BEFORE open */ | 2082 | /* carrier off reporting is important to ethtool even BEFORE open */ |
2061 | netif_carrier_off(netdev); | 2083 | netif_carrier_off(netdev); |
2062 | 2084 | ||
@@ -2939,12 +2961,11 @@ static inline int igb_set_vf_rlpml(struct igb_adapter *adapter, int size, | |||
2939 | **/ | 2961 | **/ |
2940 | static void igb_rlpml_set(struct igb_adapter *adapter) | 2962 | static void igb_rlpml_set(struct igb_adapter *adapter) |
2941 | { | 2963 | { |
2942 | u32 max_frame_size = adapter->max_frame_size; | 2964 | u32 max_frame_size; |
2943 | struct e1000_hw *hw = &adapter->hw; | 2965 | struct e1000_hw *hw = &adapter->hw; |
2944 | u16 pf_id = adapter->vfs_allocated_count; | 2966 | u16 pf_id = adapter->vfs_allocated_count; |
2945 | 2967 | ||
2946 | if (adapter->vlgrp) | 2968 | max_frame_size = adapter->max_frame_size + VLAN_TAG_SIZE; |
2947 | max_frame_size += VLAN_TAG_SIZE; | ||
2948 | 2969 | ||
2949 | /* if vfs are enabled we set RLPML to the largest possible request | 2970 | /* if vfs are enabled we set RLPML to the largest possible request |
2950 | * size and set the VMOLR RLPML to the size we need */ | 2971 | * size and set the VMOLR RLPML to the size we need */ |
@@ -5693,25 +5714,6 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector) | |||
5693 | return count < tx_ring->count; | 5714 | return count < tx_ring->count; |
5694 | } | 5715 | } |
5695 | 5716 | ||
5696 | /** | ||
5697 | * igb_receive_skb - helper function to handle rx indications | ||
5698 | * @q_vector: structure containing interrupt and ring information | ||
5699 | * @skb: packet to send up | ||
5700 | * @vlan_tag: vlan tag for packet | ||
5701 | **/ | ||
5702 | static void igb_receive_skb(struct igb_q_vector *q_vector, | ||
5703 | struct sk_buff *skb, | ||
5704 | u16 vlan_tag) | ||
5705 | { | ||
5706 | struct igb_adapter *adapter = q_vector->adapter; | ||
5707 | |||
5708 | if (vlan_tag && adapter->vlgrp) | ||
5709 | vlan_gro_receive(&q_vector->napi, adapter->vlgrp, | ||
5710 | vlan_tag, skb); | ||
5711 | else | ||
5712 | napi_gro_receive(&q_vector->napi, skb); | ||
5713 | } | ||
5714 | |||
5715 | static inline void igb_rx_checksum_adv(struct igb_ring *ring, | 5717 | static inline void igb_rx_checksum_adv(struct igb_ring *ring, |
5716 | u32 status_err, struct sk_buff *skb) | 5718 | u32 status_err, struct sk_buff *skb) |
5717 | { | 5719 | { |
@@ -5809,7 +5811,6 @@ static bool igb_clean_rx_irq_adv(struct igb_q_vector *q_vector, | |||
5809 | unsigned int i; | 5811 | unsigned int i; |
5810 | u32 staterr; | 5812 | u32 staterr; |
5811 | u16 length; | 5813 | u16 length; |
5812 | u16 vlan_tag; | ||
5813 | 5814 | ||
5814 | i = rx_ring->next_to_clean; | 5815 | i = rx_ring->next_to_clean; |
5815 | buffer_info = &rx_ring->buffer_info[i]; | 5816 | buffer_info = &rx_ring->buffer_info[i]; |
@@ -5894,10 +5895,12 @@ send_up: | |||
5894 | skb->protocol = eth_type_trans(skb, netdev); | 5895 | skb->protocol = eth_type_trans(skb, netdev); |
5895 | skb_record_rx_queue(skb, rx_ring->queue_index); | 5896 | skb_record_rx_queue(skb, rx_ring->queue_index); |
5896 | 5897 | ||
5897 | vlan_tag = ((staterr & E1000_RXD_STAT_VP) ? | 5898 | if (staterr & E1000_RXD_STAT_VP) { |
5898 | le16_to_cpu(rx_desc->wb.upper.vlan) : 0); | 5899 | u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan); |
5899 | 5900 | ||
5900 | igb_receive_skb(q_vector, skb, vlan_tag); | 5901 | __vlan_hwaccel_put_tag(skb, vid); |
5902 | } | ||
5903 | napi_gro_receive(&q_vector->napi, skb); | ||
5901 | 5904 | ||
5902 | next_desc: | 5905 | next_desc: |
5903 | rx_desc->wb.upper.status_error = 0; | 5906 | rx_desc->wb.upper.status_error = 0; |
@@ -6290,17 +6293,15 @@ s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) | |||
6290 | return 0; | 6293 | return 0; |
6291 | } | 6294 | } |
6292 | 6295 | ||
6293 | static void igb_vlan_rx_register(struct net_device *netdev, | 6296 | static void igb_vlan_mode(struct net_device *netdev, u32 features) |
6294 | struct vlan_group *grp) | ||
6295 | { | 6297 | { |
6296 | struct igb_adapter *adapter = netdev_priv(netdev); | 6298 | struct igb_adapter *adapter = netdev_priv(netdev); |
6297 | struct e1000_hw *hw = &adapter->hw; | 6299 | struct e1000_hw *hw = &adapter->hw; |
6298 | u32 ctrl, rctl; | 6300 | u32 ctrl, rctl; |
6299 | 6301 | ||
6300 | igb_irq_disable(adapter); | 6302 | igb_irq_disable(adapter); |
6301 | adapter->vlgrp = grp; | ||
6302 | 6303 | ||
6303 | if (grp) { | 6304 | if (features & NETIF_F_HW_VLAN_RX) { |
6304 | /* enable VLAN tag insert/strip */ | 6305 | /* enable VLAN tag insert/strip */ |
6305 | ctrl = rd32(E1000_CTRL); | 6306 | ctrl = rd32(E1000_CTRL); |
6306 | ctrl |= E1000_CTRL_VME; | 6307 | ctrl |= E1000_CTRL_VME; |
@@ -6334,6 +6335,8 @@ static void igb_vlan_rx_add_vid(struct net_device *netdev, u16 vid) | |||
6334 | 6335 | ||
6335 | /* add the filter since PF can receive vlans w/o entry in vlvf */ | 6336 | /* add the filter since PF can receive vlans w/o entry in vlvf */ |
6336 | igb_vfta_set(hw, vid, true); | 6337 | igb_vfta_set(hw, vid, true); |
6338 | |||
6339 | set_bit(vid, adapter->active_vlans); | ||
6337 | } | 6340 | } |
6338 | 6341 | ||
6339 | static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) | 6342 | static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) |
@@ -6344,7 +6347,6 @@ static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) | |||
6344 | s32 err; | 6347 | s32 err; |
6345 | 6348 | ||
6346 | igb_irq_disable(adapter); | 6349 | igb_irq_disable(adapter); |
6347 | vlan_group_set_device(adapter->vlgrp, vid, NULL); | ||
6348 | 6350 | ||
6349 | if (!test_bit(__IGB_DOWN, &adapter->state)) | 6351 | if (!test_bit(__IGB_DOWN, &adapter->state)) |
6350 | igb_irq_enable(adapter); | 6352 | igb_irq_enable(adapter); |
@@ -6355,20 +6357,16 @@ static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) | |||
6355 | /* if vid was not present in VLVF just remove it from table */ | 6357 | /* if vid was not present in VLVF just remove it from table */ |
6356 | if (err) | 6358 | if (err) |
6357 | igb_vfta_set(hw, vid, false); | 6359 | igb_vfta_set(hw, vid, false); |
6360 | |||
6361 | clear_bit(vid, adapter->active_vlans); | ||
6358 | } | 6362 | } |
6359 | 6363 | ||
6360 | static void igb_restore_vlan(struct igb_adapter *adapter) | 6364 | static void igb_restore_vlan(struct igb_adapter *adapter) |
6361 | { | 6365 | { |
6362 | igb_vlan_rx_register(adapter->netdev, adapter->vlgrp); | 6366 | u16 vid; |
6363 | 6367 | ||
6364 | if (adapter->vlgrp) { | 6368 | for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID) |
6365 | u16 vid; | 6369 | igb_vlan_rx_add_vid(adapter->netdev, vid); |
6366 | for (vid = 0; vid < VLAN_N_VID; vid++) { | ||
6367 | if (!vlan_group_get_device(adapter->vlgrp, vid)) | ||
6368 | continue; | ||
6369 | igb_vlan_rx_add_vid(adapter->netdev, vid); | ||
6370 | } | ||
6371 | } | ||
6372 | } | 6370 | } |
6373 | 6371 | ||
6374 | int igb_set_spd_dplx(struct igb_adapter *adapter, u32 spd, u8 dplx) | 6372 | int igb_set_spd_dplx(struct igb_adapter *adapter, u32 spd, u8 dplx) |