aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2011-07-20 00:54:06 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-21 16:47:53 -0400
commit7033c4ad87c3cf1050eb8190c93f94f5c8b9fae9 (patch)
tree52a27177b7184fdc2b84ac02f9a31f8c7941e6f7 /drivers
parentcec9c133631039f82e4a5ff3bf47b3eba14ff1aa (diff)
nes: do vlan cleanup
- unify vlan and nonvlan rx path - kill nesvnic->vlan_grp and nes_netdev_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/infiniband/hw/nes/nes_hw.c19
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.h4
-rw-r--r--drivers/infiniband/hw/nes/nes_nic.c50
3 files changed, 45 insertions, 28 deletions
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index 96fa9a4cafd..be36cbeae63 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -2917,24 +2917,19 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
2917 goto skip_rx_indicate0; 2917 goto skip_rx_indicate0;
2918 2918
2919 2919
2920 if ((cqe_misc & NES_NIC_CQE_TAG_VALID) && 2920 if (cqe_misc & NES_NIC_CQE_TAG_VALID) {
2921 (nesvnic->vlan_grp != NULL)) {
2922 vlan_tag = (u16)(le32_to_cpu( 2921 vlan_tag = (u16)(le32_to_cpu(
2923 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_TAG_PKT_TYPE_IDX]) 2922 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_TAG_PKT_TYPE_IDX])
2924 >> 16); 2923 >> 16);
2925 nes_debug(NES_DBG_CQ, "%s: Reporting stripped VLAN packet. Tag = 0x%04X\n", 2924 nes_debug(NES_DBG_CQ, "%s: Reporting stripped VLAN packet. Tag = 0x%04X\n",
2926 nesvnic->netdev->name, vlan_tag); 2925 nesvnic->netdev->name, vlan_tag);
2927 if (nes_use_lro) 2926
2928 lro_vlan_hwaccel_receive_skb(&nesvnic->lro_mgr, rx_skb, 2927 __vlan_hwaccel_put_tag(rx_skb, vlan_tag);
2929 nesvnic->vlan_grp, vlan_tag, NULL);
2930 else
2931 nes_vlan_rx(rx_skb, nesvnic->vlan_grp, vlan_tag);
2932 } else {
2933 if (nes_use_lro)
2934 lro_receive_skb(&nesvnic->lro_mgr, rx_skb, NULL);
2935 else
2936 nes_netif_rx(rx_skb);
2937 } 2928 }
2929 if (nes_use_lro)
2930 lro_receive_skb(&nesvnic->lro_mgr, rx_skb, NULL);
2931 else
2932 netif_receive_skb(rx_skb);
2938 2933
2939skip_rx_indicate0: 2934skip_rx_indicate0:
2940 ; 2935 ;
diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h
index 91594116f94..c3241479ec0 100644
--- a/drivers/infiniband/hw/nes/nes_hw.h
+++ b/drivers/infiniband/hw/nes/nes_hw.h
@@ -1211,7 +1211,6 @@ struct nes_vnic {
1211 /* void *mem; */ 1211 /* void *mem; */
1212 struct nes_device *nesdev; 1212 struct nes_device *nesdev;
1213 struct net_device *netdev; 1213 struct net_device *netdev;
1214 struct vlan_group *vlan_grp;
1215 atomic_t rx_skbs_needed; 1214 atomic_t rx_skbs_needed;
1216 atomic_t rx_skb_timer_running; 1215 atomic_t rx_skb_timer_running;
1217 int budget; 1216 int budget;
@@ -1357,7 +1356,4 @@ struct nes_terminate_hdr {
1357#define NES_LINK_RECHECK_DELAY msecs_to_jiffies(50) 1356#define NES_LINK_RECHECK_DELAY msecs_to_jiffies(50)
1358#define NES_LINK_RECHECK_MAX 60 1357#define NES_LINK_RECHECK_MAX 60
1359 1358
1360#define nes_vlan_rx vlan_hwaccel_receive_skb
1361#define nes_netif_rx netif_receive_skb
1362
1363#endif /* __NES_HW_H */ 1359#endif /* __NES_HW_H */
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
index d3a1c41cfd2..9d7ffebff21 100644
--- a/drivers/infiniband/hw/nes/nes_nic.c
+++ b/drivers/infiniband/hw/nes/nes_nic.c
@@ -1584,23 +1584,19 @@ static const struct ethtool_ops nes_ethtool_ops = {
1584 .set_pauseparam = nes_netdev_set_pauseparam, 1584 .set_pauseparam = nes_netdev_set_pauseparam,
1585}; 1585};
1586 1586
1587 1587static void nes_vlan_mode(struct net_device *netdev, struct nes_device *nesdev, u32 features)
1588static void nes_netdev_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
1589{ 1588{
1590 struct nes_vnic *nesvnic = netdev_priv(netdev);
1591 struct nes_device *nesdev = nesvnic->nesdev;
1592 struct nes_adapter *nesadapter = nesdev->nesadapter; 1589 struct nes_adapter *nesadapter = nesdev->nesadapter;
1593 u32 u32temp; 1590 u32 u32temp;
1594 unsigned long flags; 1591 unsigned long flags;
1595 1592
1596 spin_lock_irqsave(&nesadapter->phy_lock, flags); 1593 spin_lock_irqsave(&nesadapter->phy_lock, flags);
1597 nesvnic->vlan_grp = grp;
1598 1594
1599 nes_debug(NES_DBG_NETDEV, "%s: %s\n", __func__, netdev->name); 1595 nes_debug(NES_DBG_NETDEV, "%s: %s\n", __func__, netdev->name);
1600 1596
1601 /* Enable/Disable VLAN Stripping */ 1597 /* Enable/Disable VLAN Stripping */
1602 u32temp = nes_read_indexed(nesdev, NES_IDX_PCIX_DIAG); 1598 u32temp = nes_read_indexed(nesdev, NES_IDX_PCIX_DIAG);
1603 if (grp) 1599 if (features & NETIF_F_HW_VLAN_RX)
1604 u32temp &= 0xfdffffff; 1600 u32temp &= 0xfdffffff;
1605 else 1601 else
1606 u32temp |= 0x02000000; 1602 u32temp |= 0x02000000;
@@ -1609,17 +1605,44 @@ static void nes_netdev_vlan_rx_register(struct net_device *netdev, struct vlan_g
1609 spin_unlock_irqrestore(&nesadapter->phy_lock, flags); 1605 spin_unlock_irqrestore(&nesadapter->phy_lock, flags);
1610} 1606}
1611 1607
1608static u32 nes_fix_features(struct net_device *netdev, u32 features)
1609{
1610 /*
1611 * Since there is no support for separate rx/tx vlan accel
1612 * enable/disable make sure tx flag is always in same state as rx.
1613 */
1614 if (features & NETIF_F_HW_VLAN_RX)
1615 features |= NETIF_F_HW_VLAN_TX;
1616 else
1617 features &= ~NETIF_F_HW_VLAN_TX;
1618
1619 return features;
1620}
1621
1622static int nes_set_features(struct net_device *netdev, u32 features)
1623{
1624 struct nes_vnic *nesvnic = netdev_priv(netdev);
1625 struct nes_device *nesdev = nesvnic->nesdev;
1626 u32 changed = netdev->features ^ features;
1627
1628 if (changed & NETIF_F_HW_VLAN_RX)
1629 nes_vlan_mode(netdev, nesdev, features);
1630
1631 return 0;
1632}
1633
1612static const struct net_device_ops nes_netdev_ops = { 1634static const struct net_device_ops nes_netdev_ops = {
1613 .ndo_open = nes_netdev_open, 1635 .ndo_open = nes_netdev_open,
1614 .ndo_stop = nes_netdev_stop, 1636 .ndo_stop = nes_netdev_stop,
1615 .ndo_start_xmit = nes_netdev_start_xmit, 1637 .ndo_start_xmit = nes_netdev_start_xmit,
1616 .ndo_get_stats = nes_netdev_get_stats, 1638 .ndo_get_stats = nes_netdev_get_stats,
1617 .ndo_tx_timeout = nes_netdev_tx_timeout, 1639 .ndo_tx_timeout = nes_netdev_tx_timeout,
1618 .ndo_set_mac_address = nes_netdev_set_mac_address, 1640 .ndo_set_mac_address = nes_netdev_set_mac_address,
1619 .ndo_set_multicast_list = nes_netdev_set_multicast_list, 1641 .ndo_set_multicast_list = nes_netdev_set_multicast_list,
1620 .ndo_change_mtu = nes_netdev_change_mtu, 1642 .ndo_change_mtu = nes_netdev_change_mtu,
1621 .ndo_validate_addr = eth_validate_addr, 1643 .ndo_validate_addr = eth_validate_addr,
1622 .ndo_vlan_rx_register = nes_netdev_vlan_rx_register, 1644 .ndo_fix_features = nes_fix_features,
1645 .ndo_set_features = nes_set_features,
1623}; 1646};
1624 1647
1625/** 1648/**
@@ -1656,7 +1679,7 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
1656 netdev->ethtool_ops = &nes_ethtool_ops; 1679 netdev->ethtool_ops = &nes_ethtool_ops;
1657 netif_napi_add(netdev, &nesvnic->napi, nes_netdev_poll, 128); 1680 netif_napi_add(netdev, &nesvnic->napi, nes_netdev_poll, 128);
1658 nes_debug(NES_DBG_INIT, "Enabling VLAN Insert/Delete.\n"); 1681 nes_debug(NES_DBG_INIT, "Enabling VLAN Insert/Delete.\n");
1659 netdev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 1682 netdev->features |= NETIF_F_HW_VLAN_TX;
1660 1683
1661 /* Fill in the port structure */ 1684 /* Fill in the port structure */
1662 nesvnic->netdev = netdev; 1685 nesvnic->netdev = netdev;
@@ -1683,7 +1706,8 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
1683 netdev->dev_addr[5] = (u8)u64temp; 1706 netdev->dev_addr[5] = (u8)u64temp;
1684 memcpy(netdev->perm_addr, netdev->dev_addr, 6); 1707 memcpy(netdev->perm_addr, netdev->dev_addr, 6);
1685 1708
1686 netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_IP_CSUM; 1709 netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_IP_CSUM |
1710 NETIF_F_HW_VLAN_RX;
1687 if ((nesvnic->logical_port < 2) || (nesdev->nesadapter->hw_rev != NE020_REV)) 1711 if ((nesvnic->logical_port < 2) || (nesdev->nesadapter->hw_rev != NE020_REV))
1688 netdev->hw_features |= NETIF_F_TSO; 1712 netdev->hw_features |= NETIF_F_TSO;
1689 netdev->features |= netdev->hw_features; 1713 netdev->features |= netdev->hw_features;
@@ -1815,6 +1839,8 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
1815 nes_init_phy(nesdev); 1839 nes_init_phy(nesdev);
1816 } 1840 }
1817 1841
1842 nes_vlan_mode(netdev, nesdev, netdev->features);
1843
1818 return netdev; 1844 return netdev;
1819} 1845}
1820 1846