aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tg3.c
diff options
context:
space:
mode:
authorMatt Carlson <mcarlson@broadcom.com>2011-01-25 10:58:49 -0500
committerDavid S. Miller <davem@davemloft.net>2011-01-25 22:38:16 -0500
commitbf933c802763b2beb1a1d4977f00af1a78c4fb70 (patch)
treeb64a67f7a043dc30d9ab8f425f3e4ad3282e2fb8 /drivers/net/tg3.c
parent4d163b75e979833979cc401ae433cb1d7743d57e (diff)
tg3: Use new VLAN code
This patch pivots the tg3 driver to the new VLAN infrastructure. All references to vlgrp have been removed. The driver still attempts to disable VLAN tag stripping if CONFIG_VLAN_8021Q or CONFIG_VLAN_8021Q_MODULE is not defined. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Reviewed-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tg3.c')
-rw-r--r--drivers/net/tg3.c95
1 files changed, 10 insertions, 85 deletions
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index d6d081716af0..d4b29f424085 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -60,12 +60,6 @@
60#define BAR_0 0 60#define BAR_0 0
61#define BAR_2 2 61#define BAR_2 2
62 62
63#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
64#define TG3_VLAN_TAG_USED 1
65#else
66#define TG3_VLAN_TAG_USED 0
67#endif
68
69#include "tg3.h" 63#include "tg3.h"
70 64
71#define DRV_MODULE_NAME "tg3" 65#define DRV_MODULE_NAME "tg3"
@@ -134,9 +128,6 @@
134 TG3_TX_RING_SIZE) 128 TG3_TX_RING_SIZE)
135#define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1)) 129#define NEXT_TX(N) (((N) + 1) & (TG3_TX_RING_SIZE - 1))
136 130
137#define TG3_RX_DMA_ALIGN 16
138#define TG3_RX_HEADROOM ALIGN(VLAN_HLEN, TG3_RX_DMA_ALIGN)
139
140#define TG3_DMA_BYTE_ENAB 64 131#define TG3_DMA_BYTE_ENAB 64
141 132
142#define TG3_RX_STD_DMA_SZ 1536 133#define TG3_RX_STD_DMA_SZ 1536
@@ -4722,8 +4713,6 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4722 struct sk_buff *skb; 4713 struct sk_buff *skb;
4723 dma_addr_t dma_addr; 4714 dma_addr_t dma_addr;
4724 u32 opaque_key, desc_idx, *post_ptr; 4715 u32 opaque_key, desc_idx, *post_ptr;
4725 bool hw_vlan __maybe_unused = false;
4726 u16 vtag __maybe_unused = 0;
4727 4716
4728 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK; 4717 desc_idx = desc->opaque & RXD_OPAQUE_INDEX_MASK;
4729 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK; 4718 opaque_key = desc->opaque & RXD_OPAQUE_RING_MASK;
@@ -4782,12 +4771,12 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4782 tg3_recycle_rx(tnapi, tpr, opaque_key, 4771 tg3_recycle_rx(tnapi, tpr, opaque_key,
4783 desc_idx, *post_ptr); 4772 desc_idx, *post_ptr);
4784 4773
4785 copy_skb = netdev_alloc_skb(tp->dev, len + VLAN_HLEN + 4774 copy_skb = netdev_alloc_skb(tp->dev, len +
4786 TG3_RAW_IP_ALIGN); 4775 TG3_RAW_IP_ALIGN);
4787 if (copy_skb == NULL) 4776 if (copy_skb == NULL)
4788 goto drop_it_no_recycle; 4777 goto drop_it_no_recycle;
4789 4778
4790 skb_reserve(copy_skb, TG3_RAW_IP_ALIGN + VLAN_HLEN); 4779 skb_reserve(copy_skb, TG3_RAW_IP_ALIGN);
4791 skb_put(copy_skb, len); 4780 skb_put(copy_skb, len);
4792 pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE); 4781 pci_dma_sync_single_for_cpu(tp->pdev, dma_addr, len, PCI_DMA_FROMDEVICE);
4793 skb_copy_from_linear_data(skb, copy_skb->data, len); 4782 skb_copy_from_linear_data(skb, copy_skb->data, len);
@@ -4814,30 +4803,11 @@ static int tg3_rx(struct tg3_napi *tnapi, int budget)
4814 } 4803 }
4815 4804
4816 if (desc->type_flags & RXD_FLAG_VLAN && 4805 if (desc->type_flags & RXD_FLAG_VLAN &&
4817 !(tp->rx_mode & RX_MODE_KEEP_VLAN_TAG)) { 4806 !(tp->rx_mode & RX_MODE_KEEP_VLAN_TAG))
4818 vtag = desc->err_vlan & RXD_VLAN_MASK; 4807 __vlan_hwaccel_put_tag(skb,
4819#if TG3_VLAN_TAG_USED 4808 desc->err_vlan & RXD_VLAN_MASK);
4820 if (tp->vlgrp)
4821 hw_vlan = true;
4822 else
4823#endif
4824 {
4825 struct vlan_ethhdr *ve = (struct vlan_ethhdr *)
4826 __skb_push(skb, VLAN_HLEN);
4827
4828 memmove(ve, skb->data + VLAN_HLEN,
4829 ETH_ALEN * 2);
4830 ve->h_vlan_proto = htons(ETH_P_8021Q);
4831 ve->h_vlan_TCI = htons(vtag);
4832 }
4833 }
4834 4809
4835#if TG3_VLAN_TAG_USED 4810 napi_gro_receive(&tnapi->napi, skb);
4836 if (hw_vlan)
4837 vlan_gro_receive(&tnapi->napi, tp->vlgrp, vtag, skb);
4838 else
4839#endif
4840 napi_gro_receive(&tnapi->napi, skb);
4841 4811
4842 received++; 4812 received++;
4843 budget--; 4813 budget--;
@@ -5740,11 +5710,9 @@ static netdev_tx_t tg3_start_xmit(struct sk_buff *skb,
5740 base_flags |= TXD_FLAG_TCPUDP_CSUM; 5710 base_flags |= TXD_FLAG_TCPUDP_CSUM;
5741 } 5711 }
5742 5712
5743#if TG3_VLAN_TAG_USED
5744 if (vlan_tx_tag_present(skb)) 5713 if (vlan_tx_tag_present(skb))
5745 base_flags |= (TXD_FLAG_VLAN | 5714 base_flags |= (TXD_FLAG_VLAN |
5746 (vlan_tx_tag_get(skb) << 16)); 5715 (vlan_tx_tag_get(skb) << 16));
5747#endif
5748 5716
5749 len = skb_headlen(skb); 5717 len = skb_headlen(skb);
5750 5718
@@ -5986,11 +5954,10 @@ static netdev_tx_t tg3_start_xmit_dma_bug(struct sk_buff *skb,
5986 } 5954 }
5987 } 5955 }
5988 } 5956 }
5989#if TG3_VLAN_TAG_USED 5957
5990 if (vlan_tx_tag_present(skb)) 5958 if (vlan_tx_tag_present(skb))
5991 base_flags |= (TXD_FLAG_VLAN | 5959 base_flags |= (TXD_FLAG_VLAN |
5992 (vlan_tx_tag_get(skb) << 16)); 5960 (vlan_tx_tag_get(skb) << 16));
5993#endif
5994 5961
5995 if ((tp->tg3_flags3 & TG3_FLG3_USE_JUMBO_BDFLAG) && 5962 if ((tp->tg3_flags3 & TG3_FLG3_USE_JUMBO_BDFLAG) &&
5996 !mss && skb->len > VLAN_ETH_FRAME_LEN) 5963 !mss && skb->len > VLAN_ETH_FRAME_LEN)
@@ -9537,17 +9504,10 @@ static void __tg3_set_rx_mode(struct net_device *dev)
9537 rx_mode = tp->rx_mode & ~(RX_MODE_PROMISC | 9504 rx_mode = tp->rx_mode & ~(RX_MODE_PROMISC |
9538 RX_MODE_KEEP_VLAN_TAG); 9505 RX_MODE_KEEP_VLAN_TAG);
9539 9506
9507#if !defined(CONFIG_VLAN_8021Q) && !defined(CONFIG_VLAN_8021Q_MODULE)
9540 /* When ASF is in use, we always keep the RX_MODE_KEEP_VLAN_TAG 9508 /* When ASF is in use, we always keep the RX_MODE_KEEP_VLAN_TAG
9541 * flag clear. 9509 * flag clear.
9542 */ 9510 */
9543#if TG3_VLAN_TAG_USED
9544 if (!tp->vlgrp &&
9545 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF))
9546 rx_mode |= RX_MODE_KEEP_VLAN_TAG;
9547#else
9548 /* By definition, VLAN is disabled always in this
9549 * case.
9550 */
9551 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) 9511 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF))
9552 rx_mode |= RX_MODE_KEEP_VLAN_TAG; 9512 rx_mode |= RX_MODE_KEEP_VLAN_TAG;
9553#endif 9513#endif
@@ -11235,31 +11195,6 @@ static int tg3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
11235 return -EOPNOTSUPP; 11195 return -EOPNOTSUPP;
11236} 11196}
11237 11197
11238#if TG3_VLAN_TAG_USED
11239static void tg3_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
11240{
11241 struct tg3 *tp = netdev_priv(dev);
11242
11243 if (!netif_running(dev)) {
11244 tp->vlgrp = grp;
11245 return;
11246 }
11247
11248 tg3_netif_stop(tp);
11249
11250 tg3_full_lock(tp, 0);
11251
11252 tp->vlgrp = grp;
11253
11254 /* Update RX_MODE_KEEP_VLAN_TAG bit in RX_MODE register. */
11255 __tg3_set_rx_mode(dev);
11256
11257 tg3_netif_start(tp);
11258
11259 tg3_full_unlock(tp);
11260}
11261#endif
11262
11263static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) 11198static int tg3_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
11264{ 11199{
11265 struct tg3 *tp = netdev_priv(dev); 11200 struct tg3 *tp = netdev_priv(dev);
@@ -13071,9 +13006,7 @@ static struct pci_dev * __devinit tg3_find_peer(struct tg3 *);
13071 13006
13072static void inline vlan_features_add(struct net_device *dev, unsigned long flags) 13007static void inline vlan_features_add(struct net_device *dev, unsigned long flags)
13073{ 13008{
13074#if TG3_VLAN_TAG_USED
13075 dev->vlan_features |= flags; 13009 dev->vlan_features |= flags;
13076#endif
13077} 13010}
13078 13011
13079static inline u32 tg3_rx_ret_ring_size(struct tg3 *tp) 13012static inline u32 tg3_rx_ret_ring_size(struct tg3 *tp)
@@ -13835,11 +13768,11 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
13835 else 13768 else
13836 tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES; 13769 tp->tg3_flags &= ~TG3_FLAG_POLL_SERDES;
13837 13770
13838 tp->rx_offset = NET_IP_ALIGN + TG3_RX_HEADROOM; 13771 tp->rx_offset = NET_IP_ALIGN;
13839 tp->rx_copy_thresh = TG3_RX_COPY_THRESHOLD; 13772 tp->rx_copy_thresh = TG3_RX_COPY_THRESHOLD;
13840 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 && 13773 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701 &&
13841 (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) { 13774 (tp->tg3_flags & TG3_FLAG_PCIX_MODE) != 0) {
13842 tp->rx_offset -= NET_IP_ALIGN; 13775 tp->rx_offset = 0;
13843#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 13776#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
13844 tp->rx_copy_thresh = ~(u16)0; 13777 tp->rx_copy_thresh = ~(u16)0;
13845#endif 13778#endif
@@ -14603,9 +14536,6 @@ static const struct net_device_ops tg3_netdev_ops = {
14603 .ndo_do_ioctl = tg3_ioctl, 14536 .ndo_do_ioctl = tg3_ioctl,
14604 .ndo_tx_timeout = tg3_tx_timeout, 14537 .ndo_tx_timeout = tg3_tx_timeout,
14605 .ndo_change_mtu = tg3_change_mtu, 14538 .ndo_change_mtu = tg3_change_mtu,
14606#if TG3_VLAN_TAG_USED
14607 .ndo_vlan_rx_register = tg3_vlan_rx_register,
14608#endif
14609#ifdef CONFIG_NET_POLL_CONTROLLER 14539#ifdef CONFIG_NET_POLL_CONTROLLER
14610 .ndo_poll_controller = tg3_poll_controller, 14540 .ndo_poll_controller = tg3_poll_controller,
14611#endif 14541#endif
@@ -14622,9 +14552,6 @@ static const struct net_device_ops tg3_netdev_ops_dma_bug = {
14622 .ndo_do_ioctl = tg3_ioctl, 14552 .ndo_do_ioctl = tg3_ioctl,
14623 .ndo_tx_timeout = tg3_tx_timeout, 14553 .ndo_tx_timeout = tg3_tx_timeout,
14624 .ndo_change_mtu = tg3_change_mtu, 14554 .ndo_change_mtu = tg3_change_mtu,
14625#if TG3_VLAN_TAG_USED
14626 .ndo_vlan_rx_register = tg3_vlan_rx_register,
14627#endif
14628#ifdef CONFIG_NET_POLL_CONTROLLER 14555#ifdef CONFIG_NET_POLL_CONTROLLER
14629 .ndo_poll_controller = tg3_poll_controller, 14556 .ndo_poll_controller = tg3_poll_controller,
14630#endif 14557#endif
@@ -14674,9 +14601,7 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
14674 14601
14675 SET_NETDEV_DEV(dev, &pdev->dev); 14602 SET_NETDEV_DEV(dev, &pdev->dev);
14676 14603
14677#if TG3_VLAN_TAG_USED
14678 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; 14604 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
14679#endif
14680 14605
14681 tp = netdev_priv(dev); 14606 tp = netdev_priv(dev);
14682 tp->pdev = pdev; 14607 tp->pdev = pdev;