diff options
author | Jesse Gross <jesse@nicira.com> | 2010-10-20 09:56:09 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-10-21 04:26:55 -0400 |
commit | 7d0fd2117e3d0550d7987b3aff2bfbc0244cf7c6 (patch) | |
tree | e13ad645bb262cf1c796c888fbcb620c6ac8600a /drivers/net/bnx2.c | |
parent | 361ff8a6cf90d62c0071b7e532e37369bfd3ae77 (diff) |
bnx2: Update bnx2 to use new vlan accleration.
Make the bnx2 driver use the new vlan accleration model.
Signed-off-by: Jesse Gross <jesse@nicira.com>
CC: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r-- | drivers/net/bnx2.c | 97 |
1 files changed, 28 insertions, 69 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 363ca8bcc974..bf3c830e7dda 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -37,9 +37,6 @@ | |||
37 | #include <linux/ethtool.h> | 37 | #include <linux/ethtool.h> |
38 | #include <linux/mii.h> | 38 | #include <linux/mii.h> |
39 | #include <linux/if_vlan.h> | 39 | #include <linux/if_vlan.h> |
40 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | ||
41 | #define BCM_VLAN 1 | ||
42 | #endif | ||
43 | #include <net/ip.h> | 40 | #include <net/ip.h> |
44 | #include <net/tcp.h> | 41 | #include <net/tcp.h> |
45 | #include <net/checksum.h> | 42 | #include <net/checksum.h> |
@@ -3087,8 +3084,6 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) | |||
3087 | struct sw_bd *rx_buf, *next_rx_buf; | 3084 | struct sw_bd *rx_buf, *next_rx_buf; |
3088 | struct sk_buff *skb; | 3085 | struct sk_buff *skb; |
3089 | dma_addr_t dma_addr; | 3086 | dma_addr_t dma_addr; |
3090 | u16 vtag = 0; | ||
3091 | int hw_vlan __maybe_unused = 0; | ||
3092 | 3087 | ||
3093 | sw_ring_cons = RX_RING_IDX(sw_cons); | 3088 | sw_ring_cons = RX_RING_IDX(sw_cons); |
3094 | sw_ring_prod = RX_RING_IDX(sw_prod); | 3089 | sw_ring_prod = RX_RING_IDX(sw_prod); |
@@ -3168,23 +3163,8 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) | |||
3168 | goto next_rx; | 3163 | goto next_rx; |
3169 | 3164 | ||
3170 | if ((status & L2_FHDR_STATUS_L2_VLAN_TAG) && | 3165 | if ((status & L2_FHDR_STATUS_L2_VLAN_TAG) && |
3171 | !(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) { | 3166 | !(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) |
3172 | vtag = rx_hdr->l2_fhdr_vlan_tag; | 3167 | __vlan_hwaccel_put_tag(skb, rx_hdr->l2_fhdr_vlan_tag); |
3173 | #ifdef BCM_VLAN | ||
3174 | if (bp->vlgrp) | ||
3175 | hw_vlan = 1; | ||
3176 | else | ||
3177 | #endif | ||
3178 | { | ||
3179 | struct vlan_ethhdr *ve = (struct vlan_ethhdr *) | ||
3180 | __skb_push(skb, 4); | ||
3181 | |||
3182 | memmove(ve, skb->data + 4, ETH_ALEN * 2); | ||
3183 | ve->h_vlan_proto = htons(ETH_P_8021Q); | ||
3184 | ve->h_vlan_TCI = htons(vtag); | ||
3185 | len += 4; | ||
3186 | } | ||
3187 | } | ||
3188 | 3168 | ||
3189 | skb->protocol = eth_type_trans(skb, bp->dev); | 3169 | skb->protocol = eth_type_trans(skb, bp->dev); |
3190 | 3170 | ||
@@ -3211,14 +3191,7 @@ bnx2_rx_int(struct bnx2 *bp, struct bnx2_napi *bnapi, int budget) | |||
3211 | skb->rxhash = rx_hdr->l2_fhdr_hash; | 3191 | skb->rxhash = rx_hdr->l2_fhdr_hash; |
3212 | 3192 | ||
3213 | skb_record_rx_queue(skb, bnapi - &bp->bnx2_napi[0]); | 3193 | skb_record_rx_queue(skb, bnapi - &bp->bnx2_napi[0]); |
3214 | 3194 | napi_gro_receive(&bnapi->napi, skb); | |
3215 | #ifdef BCM_VLAN | ||
3216 | if (hw_vlan) | ||
3217 | vlan_gro_receive(&bnapi->napi, bp->vlgrp, vtag, skb); | ||
3218 | else | ||
3219 | #endif | ||
3220 | napi_gro_receive(&bnapi->napi, skb); | ||
3221 | |||
3222 | rx_pkt++; | 3195 | rx_pkt++; |
3223 | 3196 | ||
3224 | next_rx: | 3197 | next_rx: |
@@ -3533,13 +3506,9 @@ bnx2_set_rx_mode(struct net_device *dev) | |||
3533 | rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS | | 3506 | rx_mode = bp->rx_mode & ~(BNX2_EMAC_RX_MODE_PROMISCUOUS | |
3534 | BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG); | 3507 | BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG); |
3535 | sort_mode = 1 | BNX2_RPM_SORT_USER0_BC_EN; | 3508 | sort_mode = 1 | BNX2_RPM_SORT_USER0_BC_EN; |
3536 | #ifdef BCM_VLAN | 3509 | if (!(dev->features & NETIF_F_HW_VLAN_RX) && |
3537 | if (!bp->vlgrp && (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN)) | 3510 | (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN)) |
3538 | rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG; | 3511 | rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG; |
3539 | #else | ||
3540 | if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) | ||
3541 | rx_mode |= BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG; | ||
3542 | #endif | ||
3543 | if (dev->flags & IFF_PROMISC) { | 3512 | if (dev->flags & IFF_PROMISC) { |
3544 | /* Promiscuous mode. */ | 3513 | /* Promiscuous mode. */ |
3545 | rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS; | 3514 | rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS; |
@@ -6365,29 +6334,6 @@ bnx2_tx_timeout(struct net_device *dev) | |||
6365 | schedule_work(&bp->reset_task); | 6334 | schedule_work(&bp->reset_task); |
6366 | } | 6335 | } |
6367 | 6336 | ||
6368 | #ifdef BCM_VLAN | ||
6369 | /* Called with rtnl_lock */ | ||
6370 | static void | ||
6371 | bnx2_vlan_rx_register(struct net_device *dev, struct vlan_group *vlgrp) | ||
6372 | { | ||
6373 | struct bnx2 *bp = netdev_priv(dev); | ||
6374 | |||
6375 | if (netif_running(dev)) | ||
6376 | bnx2_netif_stop(bp, false); | ||
6377 | |||
6378 | bp->vlgrp = vlgrp; | ||
6379 | |||
6380 | if (!netif_running(dev)) | ||
6381 | return; | ||
6382 | |||
6383 | bnx2_set_rx_mode(dev); | ||
6384 | if (bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) | ||
6385 | bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1); | ||
6386 | |||
6387 | bnx2_netif_start(bp, false); | ||
6388 | } | ||
6389 | #endif | ||
6390 | |||
6391 | /* Called with netif_tx_lock. | 6337 | /* Called with netif_tx_lock. |
6392 | * bnx2_tx_int() runs without netif_tx_lock unless it needs to call | 6338 | * bnx2_tx_int() runs without netif_tx_lock unless it needs to call |
6393 | * netif_wake_queue(). | 6339 | * netif_wake_queue(). |
@@ -6428,12 +6374,11 @@ bnx2_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
6428 | vlan_tag_flags |= TX_BD_FLAGS_TCP_UDP_CKSUM; | 6374 | vlan_tag_flags |= TX_BD_FLAGS_TCP_UDP_CKSUM; |
6429 | } | 6375 | } |
6430 | 6376 | ||
6431 | #ifdef BCM_VLAN | ||
6432 | if (vlan_tx_tag_present(skb)) { | 6377 | if (vlan_tx_tag_present(skb)) { |
6433 | vlan_tag_flags |= | 6378 | vlan_tag_flags |= |
6434 | (TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16)); | 6379 | (TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16)); |
6435 | } | 6380 | } |
6436 | #endif | 6381 | |
6437 | if ((mss = skb_shinfo(skb)->gso_size)) { | 6382 | if ((mss = skb_shinfo(skb)->gso_size)) { |
6438 | u32 tcp_opt_len; | 6383 | u32 tcp_opt_len; |
6439 | struct iphdr *iph; | 6384 | struct iphdr *iph; |
@@ -7578,7 +7523,28 @@ bnx2_set_tx_csum(struct net_device *dev, u32 data) | |||
7578 | static int | 7523 | static int |
7579 | bnx2_set_flags(struct net_device *dev, u32 data) | 7524 | bnx2_set_flags(struct net_device *dev, u32 data) |
7580 | { | 7525 | { |
7581 | return ethtool_op_set_flags(dev, data, ETH_FLAG_RXHASH); | 7526 | struct bnx2 *bp = netdev_priv(dev); |
7527 | int rc; | ||
7528 | |||
7529 | if (!(bp->flags & BNX2_FLAG_CAN_KEEP_VLAN) && | ||
7530 | !(data & ETH_FLAG_RXVLAN)) | ||
7531 | return -EOPNOTSUPP; | ||
7532 | |||
7533 | rc = ethtool_op_set_flags(dev, data, ETH_FLAG_RXHASH | ETH_FLAG_RXVLAN | | ||
7534 | ETH_FLAG_TXVLAN); | ||
7535 | if (rc) | ||
7536 | return rc; | ||
7537 | |||
7538 | if ((!!(data & ETH_FLAG_RXVLAN) != | ||
7539 | !!(bp->rx_mode & BNX2_EMAC_RX_MODE_KEEP_VLAN_TAG)) && | ||
7540 | netif_running(dev)) { | ||
7541 | bnx2_netif_stop(bp, false); | ||
7542 | bnx2_set_rx_mode(dev); | ||
7543 | bnx2_fw_sync(bp, BNX2_DRV_MSG_CODE_KEEP_VLAN_UPDATE, 0, 1); | ||
7544 | bnx2_netif_start(bp, false); | ||
7545 | } | ||
7546 | |||
7547 | return 0; | ||
7582 | } | 7548 | } |
7583 | 7549 | ||
7584 | static const struct ethtool_ops bnx2_ethtool_ops = { | 7550 | static const struct ethtool_ops bnx2_ethtool_ops = { |
@@ -8318,9 +8284,6 @@ static const struct net_device_ops bnx2_netdev_ops = { | |||
8318 | .ndo_set_mac_address = bnx2_change_mac_addr, | 8284 | .ndo_set_mac_address = bnx2_change_mac_addr, |
8319 | .ndo_change_mtu = bnx2_change_mtu, | 8285 | .ndo_change_mtu = bnx2_change_mtu, |
8320 | .ndo_tx_timeout = bnx2_tx_timeout, | 8286 | .ndo_tx_timeout = bnx2_tx_timeout, |
8321 | #ifdef BCM_VLAN | ||
8322 | .ndo_vlan_rx_register = bnx2_vlan_rx_register, | ||
8323 | #endif | ||
8324 | #ifdef CONFIG_NET_POLL_CONTROLLER | 8287 | #ifdef CONFIG_NET_POLL_CONTROLLER |
8325 | .ndo_poll_controller = poll_bnx2, | 8288 | .ndo_poll_controller = poll_bnx2, |
8326 | #endif | 8289 | #endif |
@@ -8328,9 +8291,7 @@ static const struct net_device_ops bnx2_netdev_ops = { | |||
8328 | 8291 | ||
8329 | static void inline vlan_features_add(struct net_device *dev, unsigned long flags) | 8292 | static void inline vlan_features_add(struct net_device *dev, unsigned long flags) |
8330 | { | 8293 | { |
8331 | #ifdef BCM_VLAN | ||
8332 | dev->vlan_features |= flags; | 8294 | dev->vlan_features |= flags; |
8333 | #endif | ||
8334 | } | 8295 | } |
8335 | 8296 | ||
8336 | static int __devinit | 8297 | static int __devinit |
@@ -8379,9 +8340,7 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
8379 | dev->features |= NETIF_F_IPV6_CSUM; | 8340 | dev->features |= NETIF_F_IPV6_CSUM; |
8380 | vlan_features_add(dev, NETIF_F_IPV6_CSUM); | 8341 | vlan_features_add(dev, NETIF_F_IPV6_CSUM); |
8381 | } | 8342 | } |
8382 | #ifdef BCM_VLAN | ||
8383 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; | 8343 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; |
8384 | #endif | ||
8385 | dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN; | 8344 | dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN; |
8386 | vlan_features_add(dev, NETIF_F_TSO | NETIF_F_TSO_ECN); | 8345 | vlan_features_add(dev, NETIF_F_TSO | NETIF_F_TSO_ECN); |
8387 | if (CHIP_NUM(bp) == CHIP_NUM_5709) { | 8346 | if (CHIP_NUM(bp) == CHIP_NUM_5709) { |