aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/atl1e
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2011-07-20 00:54:13 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-21 16:47:54 -0400
commit2707fffc0f330662d75ff609470700100392673f (patch)
tree30f9185235b3a88f3fe4a7c1e8b685b2f84b2847 /drivers/net/atl1e
parent46facce9130ee5a4e4863094049af85c4a757356 (diff)
atl1e: do vlan cleanup
- unify vlan and nonvlan rx path - kill adapter->vlgrp and atl1e_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/atl1e')
-rw-r--r--drivers/net/atl1e/atl1e.h1
-rw-r--r--drivers/net/atl1e/atl1e_main.c79
2 files changed, 50 insertions, 30 deletions
diff --git a/drivers/net/atl1e/atl1e.h b/drivers/net/atl1e/atl1e.h
index 8c8181b53286..829b5ad71d0d 100644
--- a/drivers/net/atl1e/atl1e.h
+++ b/drivers/net/atl1e/atl1e.h
@@ -433,7 +433,6 @@ struct atl1e_rx_ring {
433struct atl1e_adapter { 433struct atl1e_adapter {
434 struct net_device *netdev; 434 struct net_device *netdev;
435 struct pci_dev *pdev; 435 struct pci_dev *pdev;
436 struct vlan_group *vlgrp;
437 struct napi_struct napi; 436 struct napi_struct napi;
438 struct mii_if_info mii; /* MII interface info */ 437 struct mii_if_info mii; /* MII interface info */
439 struct atl1e_hw hw; 438 struct atl1e_hw hw;
diff --git a/drivers/net/atl1e/atl1e_main.c b/drivers/net/atl1e/atl1e_main.c
index c3c5db13cf22..d8d411998fa3 100644
--- a/drivers/net/atl1e/atl1e_main.c
+++ b/drivers/net/atl1e/atl1e_main.c
@@ -313,8 +313,18 @@ static void atl1e_set_multi(struct net_device *netdev)
313 } 313 }
314} 314}
315 315
316static void atl1e_vlan_rx_register(struct net_device *netdev, 316static void __atl1e_vlan_mode(u32 features, u32 *mac_ctrl_data)
317 struct vlan_group *grp) 317{
318 if (features & NETIF_F_HW_VLAN_RX) {
319 /* enable VLAN tag insert/strip */
320 *mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
321 } else {
322 /* disable VLAN tag insert/strip */
323 *mac_ctrl_data &= ~MAC_CTRL_RMV_VLAN;
324 }
325}
326
327static void atl1e_vlan_mode(struct net_device *netdev, u32 features)
318{ 328{
319 struct atl1e_adapter *adapter = netdev_priv(netdev); 329 struct atl1e_adapter *adapter = netdev_priv(netdev);
320 u32 mac_ctrl_data = 0; 330 u32 mac_ctrl_data = 0;
@@ -322,18 +332,8 @@ static void atl1e_vlan_rx_register(struct net_device *netdev,
322 netdev_dbg(adapter->netdev, "%s\n", __func__); 332 netdev_dbg(adapter->netdev, "%s\n", __func__);
323 333
324 atl1e_irq_disable(adapter); 334 atl1e_irq_disable(adapter);
325
326 adapter->vlgrp = grp;
327 mac_ctrl_data = AT_READ_REG(&adapter->hw, REG_MAC_CTRL); 335 mac_ctrl_data = AT_READ_REG(&adapter->hw, REG_MAC_CTRL);
328 336 __atl1e_vlan_mode(features, &mac_ctrl_data);
329 if (grp) {
330 /* enable VLAN tag insert/strip */
331 mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
332 } else {
333 /* disable VLAN tag insert/strip */
334 mac_ctrl_data &= ~MAC_CTRL_RMV_VLAN;
335 }
336
337 AT_WRITE_REG(&adapter->hw, REG_MAC_CTRL, mac_ctrl_data); 337 AT_WRITE_REG(&adapter->hw, REG_MAC_CTRL, mac_ctrl_data);
338 atl1e_irq_enable(adapter); 338 atl1e_irq_enable(adapter);
339} 339}
@@ -341,8 +341,9 @@ static void atl1e_vlan_rx_register(struct net_device *netdev,
341static void atl1e_restore_vlan(struct atl1e_adapter *adapter) 341static void atl1e_restore_vlan(struct atl1e_adapter *adapter)
342{ 342{
343 netdev_dbg(adapter->netdev, "%s\n", __func__); 343 netdev_dbg(adapter->netdev, "%s\n", __func__);
344 atl1e_vlan_rx_register(adapter->netdev, adapter->vlgrp); 344 atl1e_vlan_mode(adapter->netdev, adapter->netdev->features);
345} 345}
346
346/* 347/*
347 * atl1e_set_mac - Change the Ethernet Address of the NIC 348 * atl1e_set_mac - Change the Ethernet Address of the NIC
348 * @netdev: network interface device structure 349 * @netdev: network interface device structure
@@ -369,6 +370,30 @@ static int atl1e_set_mac_addr(struct net_device *netdev, void *p)
369 return 0; 370 return 0;
370} 371}
371 372
373static u32 atl1e_fix_features(struct net_device *netdev, u32 features)
374{
375 /*
376 * Since there is no support for separate rx/tx vlan accel
377 * enable/disable make sure tx flag is always in same state as rx.
378 */
379 if (features & NETIF_F_HW_VLAN_RX)
380 features |= NETIF_F_HW_VLAN_TX;
381 else
382 features &= ~NETIF_F_HW_VLAN_TX;
383
384 return features;
385}
386
387static int atl1e_set_features(struct net_device *netdev, u32 features)
388{
389 u32 changed = netdev->features ^ features;
390
391 if (changed & NETIF_F_HW_VLAN_RX)
392 atl1e_vlan_mode(netdev, features);
393
394 return 0;
395}
396
372/* 397/*
373 * atl1e_change_mtu - Change the Maximum Transfer Unit 398 * atl1e_change_mtu - Change the Maximum Transfer Unit
374 * @netdev: network interface device structure 399 * @netdev: network interface device structure
@@ -1039,8 +1064,7 @@ static void atl1e_setup_mac_ctrl(struct atl1e_adapter *adapter)
1039 value |= (((u32)adapter->hw.preamble_len & 1064 value |= (((u32)adapter->hw.preamble_len &
1040 MAC_CTRL_PRMLEN_MASK) << MAC_CTRL_PRMLEN_SHIFT); 1065 MAC_CTRL_PRMLEN_MASK) << MAC_CTRL_PRMLEN_SHIFT);
1041 1066
1042 if (adapter->vlgrp) 1067 __atl1e_vlan_mode(netdev->features, &value);
1043 value |= MAC_CTRL_RMV_VLAN;
1044 1068
1045 value |= MAC_CTRL_BC_EN; 1069 value |= MAC_CTRL_BC_EN;
1046 if (netdev->flags & IFF_PROMISC) 1070 if (netdev->flags & IFF_PROMISC)
@@ -1423,19 +1447,16 @@ static void atl1e_clean_rx_irq(struct atl1e_adapter *adapter, u8 que,
1423 skb->protocol = eth_type_trans(skb, netdev); 1447 skb->protocol = eth_type_trans(skb, netdev);
1424 atl1e_rx_checksum(adapter, skb, prrs); 1448 atl1e_rx_checksum(adapter, skb, prrs);
1425 1449
1426 if (unlikely(adapter->vlgrp && 1450 if (prrs->pkt_flag & RRS_IS_VLAN_TAG) {
1427 (prrs->pkt_flag & RRS_IS_VLAN_TAG))) {
1428 u16 vlan_tag = (prrs->vtag >> 4) | 1451 u16 vlan_tag = (prrs->vtag >> 4) |
1429 ((prrs->vtag & 7) << 13) | 1452 ((prrs->vtag & 7) << 13) |
1430 ((prrs->vtag & 8) << 9); 1453 ((prrs->vtag & 8) << 9);
1431 netdev_dbg(netdev, 1454 netdev_dbg(netdev,
1432 "RXD VLAN TAG<RRD>=0x%04x\n", 1455 "RXD VLAN TAG<RRD>=0x%04x\n",
1433 prrs->vtag); 1456 prrs->vtag);
1434 vlan_hwaccel_receive_skb(skb, adapter->vlgrp, 1457 __vlan_hwaccel_put_tag(skb, vlan_tag);
1435 vlan_tag);
1436 } else {
1437 netif_receive_skb(skb);
1438 } 1458 }
1459 netif_receive_skb(skb);
1439 1460
1440skip_pkt: 1461skip_pkt:
1441 /* skip current packet whether it's ok or not. */ 1462 /* skip current packet whether it's ok or not. */
@@ -1811,7 +1832,7 @@ static netdev_tx_t atl1e_xmit_frame(struct sk_buff *skb,
1811 1832
1812 tpd = atl1e_get_tpd(adapter); 1833 tpd = atl1e_get_tpd(adapter);
1813 1834
1814 if (unlikely(vlan_tx_tag_present(skb))) { 1835 if (vlan_tx_tag_present(skb)) {
1815 u16 vlan_tag = vlan_tx_tag_get(skb); 1836 u16 vlan_tag = vlan_tx_tag_get(skb);
1816 u16 atl1e_vlan_tag; 1837 u16 atl1e_vlan_tag;
1817 1838
@@ -2093,8 +2114,7 @@ static int atl1e_suspend(struct pci_dev *pdev, pm_message_t state)
2093 MAC_CTRL_PRMLEN_MASK) << 2114 MAC_CTRL_PRMLEN_MASK) <<
2094 MAC_CTRL_PRMLEN_SHIFT); 2115 MAC_CTRL_PRMLEN_SHIFT);
2095 2116
2096 if (adapter->vlgrp) 2117 __atl1e_vlan_mode(netdev->features, &mac_ctrl_data);
2097 mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
2098 2118
2099 /* magic packet maybe Broadcast&multicast&Unicast frame */ 2119 /* magic packet maybe Broadcast&multicast&Unicast frame */
2100 if (wufc & AT_WUFC_MAG) 2120 if (wufc & AT_WUFC_MAG)
@@ -2195,10 +2215,11 @@ static const struct net_device_ops atl1e_netdev_ops = {
2195 .ndo_set_multicast_list = atl1e_set_multi, 2215 .ndo_set_multicast_list = atl1e_set_multi,
2196 .ndo_validate_addr = eth_validate_addr, 2216 .ndo_validate_addr = eth_validate_addr,
2197 .ndo_set_mac_address = atl1e_set_mac_addr, 2217 .ndo_set_mac_address = atl1e_set_mac_addr,
2218 .ndo_fix_features = atl1e_fix_features,
2219 .ndo_set_features = atl1e_set_features,
2198 .ndo_change_mtu = atl1e_change_mtu, 2220 .ndo_change_mtu = atl1e_change_mtu,
2199 .ndo_do_ioctl = atl1e_ioctl, 2221 .ndo_do_ioctl = atl1e_ioctl,
2200 .ndo_tx_timeout = atl1e_tx_timeout, 2222 .ndo_tx_timeout = atl1e_tx_timeout,
2201 .ndo_vlan_rx_register = atl1e_vlan_rx_register,
2202#ifdef CONFIG_NET_POLL_CONTROLLER 2223#ifdef CONFIG_NET_POLL_CONTROLLER
2203 .ndo_poll_controller = atl1e_netpoll, 2224 .ndo_poll_controller = atl1e_netpoll,
2204#endif 2225#endif
@@ -2217,9 +2238,9 @@ static int atl1e_init_netdev(struct net_device *netdev, struct pci_dev *pdev)
2217 atl1e_set_ethtool_ops(netdev); 2238 atl1e_set_ethtool_ops(netdev);
2218 2239
2219 netdev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO | 2240 netdev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO |
2220 NETIF_F_HW_VLAN_TX; 2241 NETIF_F_HW_VLAN_RX;
2221 netdev->features = netdev->hw_features | 2242 netdev->features = netdev->hw_features | NETIF_F_LLTX |
2222 NETIF_F_HW_VLAN_RX | NETIF_F_LLTX; 2243 NETIF_F_HW_VLAN_TX;
2223 2244
2224 return 0; 2245 return 0;
2225} 2246}