aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2011-07-20 00:54:34 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-21 16:47:56 -0400
commitdc437974af52e78f2736543dfee94cc385dae6e9 (patch)
tree390495ba1c59cb3a16d430d60ba6b64066340428 /drivers
parent924917098e4bc3561a372a6eb36993e7c3bb02f2 (diff)
atl2: do vlan cleanup
- unify vlan and nonvlan rx path - kill adapter->vlgrp and atl2_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')
-rw-r--r--drivers/net/atlx/atl2.c78
-rw-r--r--drivers/net/atlx/atl2.h3
2 files changed, 48 insertions, 33 deletions
diff --git a/drivers/net/atlx/atl2.c b/drivers/net/atlx/atl2.c
index 24e15926cee..e0f87cf1e2b 100644
--- a/drivers/net/atlx/atl2.c
+++ b/drivers/net/atlx/atl2.c
@@ -361,36 +361,59 @@ static inline void atl2_irq_disable(struct atl2_adapter *adapter)
361 synchronize_irq(adapter->pdev->irq); 361 synchronize_irq(adapter->pdev->irq);
362} 362}
363 363
364#ifdef NETIF_F_HW_VLAN_TX 364static void __atl2_vlan_mode(u32 features, u32 *ctrl)
365static void atl2_vlan_rx_register(struct net_device *netdev, 365{
366 struct vlan_group *grp) 366 if (features & NETIF_F_HW_VLAN_RX) {
367 /* enable VLAN tag insert/strip */
368 *ctrl |= MAC_CTRL_RMV_VLAN;
369 } else {
370 /* disable VLAN tag insert/strip */
371 *ctrl &= ~MAC_CTRL_RMV_VLAN;
372 }
373}
374
375static void atl2_vlan_mode(struct net_device *netdev, u32 features)
367{ 376{
368 struct atl2_adapter *adapter = netdev_priv(netdev); 377 struct atl2_adapter *adapter = netdev_priv(netdev);
369 u32 ctrl; 378 u32 ctrl;
370 379
371 atl2_irq_disable(adapter); 380 atl2_irq_disable(adapter);
372 adapter->vlgrp = grp;
373 381
374 if (grp) { 382 ctrl = ATL2_READ_REG(&adapter->hw, REG_MAC_CTRL);
375 /* enable VLAN tag insert/strip */ 383 __atl2_vlan_mode(features, &ctrl);
376 ctrl = ATL2_READ_REG(&adapter->hw, REG_MAC_CTRL); 384 ATL2_WRITE_REG(&adapter->hw, REG_MAC_CTRL, ctrl);
377 ctrl |= MAC_CTRL_RMV_VLAN;
378 ATL2_WRITE_REG(&adapter->hw, REG_MAC_CTRL, ctrl);
379 } else {
380 /* disable VLAN tag insert/strip */
381 ctrl = ATL2_READ_REG(&adapter->hw, REG_MAC_CTRL);
382 ctrl &= ~MAC_CTRL_RMV_VLAN;
383 ATL2_WRITE_REG(&adapter->hw, REG_MAC_CTRL, ctrl);
384 }
385 385
386 atl2_irq_enable(adapter); 386 atl2_irq_enable(adapter);
387} 387}
388 388
389static void atl2_restore_vlan(struct atl2_adapter *adapter) 389static void atl2_restore_vlan(struct atl2_adapter *adapter)
390{ 390{
391 atl2_vlan_rx_register(adapter->netdev, adapter->vlgrp); 391 atl2_vlan_mode(adapter->netdev, adapter->netdev->features);
392}
393
394static u32 atl2_fix_features(struct net_device *netdev, u32 features)
395{
396 /*
397 * Since there is no support for separate rx/tx vlan accel
398 * enable/disable make sure tx flag is always in same state as rx.
399 */
400 if (features & NETIF_F_HW_VLAN_RX)
401 features |= NETIF_F_HW_VLAN_TX;
402 else
403 features &= ~NETIF_F_HW_VLAN_TX;
404
405 return features;
406}
407
408static int atl2_set_features(struct net_device *netdev, u32 features)
409{
410 u32 changed = netdev->features ^ features;
411
412 if (changed & NETIF_F_HW_VLAN_RX)
413 atl2_vlan_mode(netdev, features);
414
415 return 0;
392} 416}
393#endif
394 417
395static void atl2_intr_rx(struct atl2_adapter *adapter) 418static void atl2_intr_rx(struct atl2_adapter *adapter)
396{ 419{
@@ -424,14 +447,13 @@ static void atl2_intr_rx(struct atl2_adapter *adapter)
424 memcpy(skb->data, rxd->packet, rx_size); 447 memcpy(skb->data, rxd->packet, rx_size);
425 skb_put(skb, rx_size); 448 skb_put(skb, rx_size);
426 skb->protocol = eth_type_trans(skb, netdev); 449 skb->protocol = eth_type_trans(skb, netdev);
427#ifdef NETIF_F_HW_VLAN_TX 450 if (rxd->status.vlan) {
428 if (adapter->vlgrp && (rxd->status.vlan)) {
429 u16 vlan_tag = (rxd->status.vtag>>4) | 451 u16 vlan_tag = (rxd->status.vtag>>4) |
430 ((rxd->status.vtag&7) << 13) | 452 ((rxd->status.vtag&7) << 13) |
431 ((rxd->status.vtag&8) << 9); 453 ((rxd->status.vtag&8) << 9);
432 vlan_hwaccel_rx(skb, adapter->vlgrp, vlan_tag); 454
433 } else 455 __vlan_hwaccel_put_tag(skb, vlan_tag);
434#endif 456 }
435 netif_rx(skb); 457 netif_rx(skb);
436 netdev->stats.rx_bytes += rx_size; 458 netdev->stats.rx_bytes += rx_size;
437 netdev->stats.rx_packets++; 459 netdev->stats.rx_packets++;
@@ -704,9 +726,7 @@ static int atl2_open(struct net_device *netdev)
704 atl2_set_multi(netdev); 726 atl2_set_multi(netdev);
705 init_ring_ptrs(adapter); 727 init_ring_ptrs(adapter);
706 728
707#ifdef NETIF_F_HW_VLAN_TX
708 atl2_restore_vlan(adapter); 729 atl2_restore_vlan(adapter);
709#endif
710 730
711 if (atl2_configure(adapter)) { 731 if (atl2_configure(adapter)) {
712 err = -EIO; 732 err = -EIO;
@@ -1082,9 +1102,7 @@ static int atl2_up(struct atl2_adapter *adapter)
1082 atl2_set_multi(netdev); 1102 atl2_set_multi(netdev);
1083 init_ring_ptrs(adapter); 1103 init_ring_ptrs(adapter);
1084 1104
1085#ifdef NETIF_F_HW_VLAN_TX
1086 atl2_restore_vlan(adapter); 1105 atl2_restore_vlan(adapter);
1087#endif
1088 1106
1089 if (atl2_configure(adapter)) { 1107 if (atl2_configure(adapter)) {
1090 err = -EIO; 1108 err = -EIO;
@@ -1145,8 +1163,7 @@ static void atl2_setup_mac_ctrl(struct atl2_adapter *adapter)
1145 MAC_CTRL_PRMLEN_SHIFT); 1163 MAC_CTRL_PRMLEN_SHIFT);
1146 1164
1147 /* vlan */ 1165 /* vlan */
1148 if (adapter->vlgrp) 1166 __atl2_vlan_mode(netdev->features, &value);
1149 value |= MAC_CTRL_RMV_VLAN;
1150 1167
1151 /* filter mode */ 1168 /* filter mode */
1152 value |= MAC_CTRL_BC_EN; 1169 value |= MAC_CTRL_BC_EN;
@@ -1312,9 +1329,10 @@ static const struct net_device_ops atl2_netdev_ops = {
1312 .ndo_validate_addr = eth_validate_addr, 1329 .ndo_validate_addr = eth_validate_addr,
1313 .ndo_set_mac_address = atl2_set_mac, 1330 .ndo_set_mac_address = atl2_set_mac,
1314 .ndo_change_mtu = atl2_change_mtu, 1331 .ndo_change_mtu = atl2_change_mtu,
1332 .ndo_fix_features = atl2_fix_features,
1333 .ndo_set_features = atl2_set_features,
1315 .ndo_do_ioctl = atl2_ioctl, 1334 .ndo_do_ioctl = atl2_ioctl,
1316 .ndo_tx_timeout = atl2_tx_timeout, 1335 .ndo_tx_timeout = atl2_tx_timeout,
1317 .ndo_vlan_rx_register = atl2_vlan_rx_register,
1318#ifdef CONFIG_NET_POLL_CONTROLLER 1336#ifdef CONFIG_NET_POLL_CONTROLLER
1319 .ndo_poll_controller = atl2_poll_controller, 1337 .ndo_poll_controller = atl2_poll_controller,
1320#endif 1338#endif
@@ -1410,7 +1428,7 @@ static int __devinit atl2_probe(struct pci_dev *pdev,
1410 1428
1411 err = -EIO; 1429 err = -EIO;
1412 1430
1413 netdev->hw_features = NETIF_F_SG; 1431 netdev->hw_features = NETIF_F_SG | NETIF_F_HW_VLAN_RX;
1414 netdev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX); 1432 netdev->features |= (NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX);
1415 1433
1416 /* Init PHY as early as possible due to power saving issue */ 1434 /* Init PHY as early as possible due to power saving issue */
diff --git a/drivers/net/atlx/atl2.h b/drivers/net/atlx/atl2.h
index 927e4de6474..78344ddf4bf 100644
--- a/drivers/net/atlx/atl2.h
+++ b/drivers/net/atlx/atl2.h
@@ -453,9 +453,6 @@ struct atl2_adapter {
453 /* OS defined structs */ 453 /* OS defined structs */
454 struct net_device *netdev; 454 struct net_device *netdev;
455 struct pci_dev *pdev; 455 struct pci_dev *pdev;
456#ifdef NETIF_F_HW_VLAN_TX
457 struct vlan_group *vlgrp;
458#endif
459 u32 wol; 456 u32 wol;
460 u16 link_speed; 457 u16 link_speed;
461 u16 link_duplex; 458 u16 link_duplex;