Commit 46facce9 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

atl1c: do vlan cleanup

- unify vlan and nonvlan rx path
- kill adapter->vlgrp and atl1c_vlan_rx_register
- allow to turn on/off rx/tx vlan accel via ethtool (set_features)
Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c8d9e6dd
...@@ -555,7 +555,6 @@ struct atl1c_smb { ...@@ -555,7 +555,6 @@ struct atl1c_smb {
struct atl1c_adapter { struct atl1c_adapter {
struct net_device *netdev; struct net_device *netdev;
struct pci_dev *pdev; struct pci_dev *pdev;
struct vlan_group *vlgrp;
struct napi_struct napi; struct napi_struct napi;
struct atl1c_hw hw; struct atl1c_hw hw;
struct atl1c_hw_stats hw_stats; struct atl1c_hw_stats hw_stats;
......
...@@ -411,29 +411,29 @@ static void atl1c_set_multi(struct net_device *netdev) ...@@ -411,29 +411,29 @@ static void atl1c_set_multi(struct net_device *netdev)
} }
} }
static void atl1c_vlan_rx_register(struct net_device *netdev, static void __atl1c_vlan_mode(u32 features, u32 *mac_ctrl_data)
struct vlan_group *grp) {
if (features & NETIF_F_HW_VLAN_RX) {
/* enable VLAN tag insert/strip */
*mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
} else {
/* disable VLAN tag insert/strip */
*mac_ctrl_data &= ~MAC_CTRL_RMV_VLAN;
}
}
static void atl1c_vlan_mode(struct net_device *netdev, u32 features)
{ {
struct atl1c_adapter *adapter = netdev_priv(netdev); struct atl1c_adapter *adapter = netdev_priv(netdev);
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
u32 mac_ctrl_data = 0; u32 mac_ctrl_data = 0;
if (netif_msg_pktdata(adapter)) if (netif_msg_pktdata(adapter))
dev_dbg(&pdev->dev, "atl1c_vlan_rx_register\n"); dev_dbg(&pdev->dev, "atl1c_vlan_mode\n");
atl1c_irq_disable(adapter); atl1c_irq_disable(adapter);
adapter->vlgrp = grp;
AT_READ_REG(&adapter->hw, REG_MAC_CTRL, &mac_ctrl_data); AT_READ_REG(&adapter->hw, REG_MAC_CTRL, &mac_ctrl_data);
__atl1c_vlan_mode(features, &mac_ctrl_data);
if (grp) {
/* enable VLAN tag insert/strip */
mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
} else {
/* disable VLAN tag insert/strip */
mac_ctrl_data &= ~MAC_CTRL_RMV_VLAN;
}
AT_WRITE_REG(&adapter->hw, REG_MAC_CTRL, mac_ctrl_data); AT_WRITE_REG(&adapter->hw, REG_MAC_CTRL, mac_ctrl_data);
atl1c_irq_enable(adapter); atl1c_irq_enable(adapter);
} }
...@@ -443,9 +443,10 @@ static void atl1c_restore_vlan(struct atl1c_adapter *adapter) ...@@ -443,9 +443,10 @@ static void atl1c_restore_vlan(struct atl1c_adapter *adapter)
struct pci_dev *pdev = adapter->pdev; struct pci_dev *pdev = adapter->pdev;
if (netif_msg_pktdata(adapter)) if (netif_msg_pktdata(adapter))
dev_dbg(&pdev->dev, "atl1c_restore_vlan !"); dev_dbg(&pdev->dev, "atl1c_restore_vlan\n");
atl1c_vlan_rx_register(adapter->netdev, adapter->vlgrp); atl1c_vlan_mode(adapter->netdev, adapter->netdev->features);
} }
/* /*
* atl1c_set_mac - Change the Ethernet Address of the NIC * atl1c_set_mac - Change the Ethernet Address of the NIC
* @netdev: network interface device structure * @netdev: network interface device structure
...@@ -483,12 +484,31 @@ static void atl1c_set_rxbufsize(struct atl1c_adapter *adapter, ...@@ -483,12 +484,31 @@ static void atl1c_set_rxbufsize(struct atl1c_adapter *adapter,
static u32 atl1c_fix_features(struct net_device *netdev, u32 features) static u32 atl1c_fix_features(struct net_device *netdev, u32 features)
{ {
/*
* Since there is no support for separate rx/tx vlan accel
* enable/disable make sure tx flag is always in same state as rx.
*/
if (features & NETIF_F_HW_VLAN_RX)
features |= NETIF_F_HW_VLAN_TX;
else
features &= ~NETIF_F_HW_VLAN_TX;
if (netdev->mtu > MAX_TSO_FRAME_SIZE) if (netdev->mtu > MAX_TSO_FRAME_SIZE)
features &= ~(NETIF_F_TSO | NETIF_F_TSO6); features &= ~(NETIF_F_TSO | NETIF_F_TSO6);
return features; return features;
} }
static int atl1c_set_features(struct net_device *netdev, u32 features)
{
u32 changed = netdev->features ^ features;
if (changed & NETIF_F_HW_VLAN_RX)
atl1c_vlan_mode(netdev, features);
return 0;
}
/* /*
* atl1c_change_mtu - Change the Maximum Transfer Unit * atl1c_change_mtu - Change the Maximum Transfer Unit
* @netdev: network interface device structure * @netdev: network interface device structure
...@@ -1433,8 +1453,7 @@ static void atl1c_setup_mac_ctrl(struct atl1c_adapter *adapter) ...@@ -1433,8 +1453,7 @@ static void atl1c_setup_mac_ctrl(struct atl1c_adapter *adapter)
mac_ctrl_data |= ((hw->preamble_len & MAC_CTRL_PRMLEN_MASK) << mac_ctrl_data |= ((hw->preamble_len & MAC_CTRL_PRMLEN_MASK) <<
MAC_CTRL_PRMLEN_SHIFT); MAC_CTRL_PRMLEN_SHIFT);
if (adapter->vlgrp) __atl1c_vlan_mode(netdev->features, &mac_ctrl_data);
mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
mac_ctrl_data |= MAC_CTRL_BC_EN; mac_ctrl_data |= MAC_CTRL_BC_EN;
if (netdev->flags & IFF_PROMISC) if (netdev->flags & IFF_PROMISC)
...@@ -1878,13 +1897,13 @@ static void atl1c_clean_rx_irq(struct atl1c_adapter *adapter, u8 que, ...@@ -1878,13 +1897,13 @@ static void atl1c_clean_rx_irq(struct atl1c_adapter *adapter, u8 que,
skb_put(skb, length - ETH_FCS_LEN); skb_put(skb, length - ETH_FCS_LEN);
skb->protocol = eth_type_trans(skb, netdev); skb->protocol = eth_type_trans(skb, netdev);
atl1c_rx_checksum(adapter, skb, rrs); atl1c_rx_checksum(adapter, skb, rrs);
if (unlikely(adapter->vlgrp) && rrs->word3 & RRS_VLAN_INS) { if (rrs->word3 & RRS_VLAN_INS) {
u16 vlan; u16 vlan;
AT_TAG_TO_VLAN(rrs->vlan_tag, vlan); AT_TAG_TO_VLAN(rrs->vlan_tag, vlan);
vlan = le16_to_cpu(vlan); vlan = le16_to_cpu(vlan);
vlan_hwaccel_receive_skb(skb, adapter->vlgrp, vlan); __vlan_hwaccel_put_tag(skb, vlan);
} else }
netif_receive_skb(skb); netif_receive_skb(skb);
(*work_done)++; (*work_done)++;
...@@ -2507,8 +2526,7 @@ static int atl1c_suspend(struct device *dev) ...@@ -2507,8 +2526,7 @@ static int atl1c_suspend(struct device *dev)
/* clear phy interrupt */ /* clear phy interrupt */
atl1c_read_phy_reg(hw, MII_ISR, &mii_intr_status_data); atl1c_read_phy_reg(hw, MII_ISR, &mii_intr_status_data);
/* Config MAC Ctrl register */ /* Config MAC Ctrl register */
if (adapter->vlgrp) __atl1c_vlan_mode(netdev->features, &mac_ctrl_data);
mac_ctrl_data |= MAC_CTRL_RMV_VLAN;
/* magic packet maybe Broadcast&multicast&Unicast frame */ /* magic packet maybe Broadcast&multicast&Unicast frame */
if (wufc & AT_WUFC_MAG) if (wufc & AT_WUFC_MAG)
...@@ -2585,10 +2603,10 @@ static const struct net_device_ops atl1c_netdev_ops = { ...@@ -2585,10 +2603,10 @@ static const struct net_device_ops atl1c_netdev_ops = {
.ndo_set_multicast_list = atl1c_set_multi, .ndo_set_multicast_list = atl1c_set_multi,
.ndo_change_mtu = atl1c_change_mtu, .ndo_change_mtu = atl1c_change_mtu,
.ndo_fix_features = atl1c_fix_features, .ndo_fix_features = atl1c_fix_features,
.ndo_set_features = atl1c_set_features,
.ndo_do_ioctl = atl1c_ioctl, .ndo_do_ioctl = atl1c_ioctl,
.ndo_tx_timeout = atl1c_tx_timeout, .ndo_tx_timeout = atl1c_tx_timeout,
.ndo_get_stats = atl1c_get_stats, .ndo_get_stats = atl1c_get_stats,
.ndo_vlan_rx_register = atl1c_vlan_rx_register,
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = atl1c_netpoll, .ndo_poll_controller = atl1c_netpoll,
#endif #endif
...@@ -2607,11 +2625,11 @@ static int atl1c_init_netdev(struct net_device *netdev, struct pci_dev *pdev) ...@@ -2607,11 +2625,11 @@ static int atl1c_init_netdev(struct net_device *netdev, struct pci_dev *pdev)
/* TODO: add when ready */ /* TODO: add when ready */
netdev->hw_features = NETIF_F_SG | netdev->hw_features = NETIF_F_SG |
NETIF_F_HW_CSUM | NETIF_F_HW_CSUM |
NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX |
NETIF_F_TSO | NETIF_F_TSO |
NETIF_F_TSO6; NETIF_F_TSO6;
netdev->features = netdev->hw_features | netdev->features = netdev->hw_features |
NETIF_F_HW_VLAN_RX; NETIF_F_HW_VLAN_TX;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment