Skip to content

Commit

Permalink
bnad: do vlan cleanup
Browse files Browse the repository at this point in the history
- unify vlan and nonvlan rx path
- kill bnad->vlan_grp and bnad_vlan_rx_register

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Jul 21, 2011
1 parent 2707fff commit f859d7c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 39 deletions.
55 changes: 17 additions & 38 deletions drivers/net/bna/bnad.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* All rights reserved
* www.brocade.com
*/
#include <linux/bitops.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/etherdevice.h>
Expand All @@ -24,6 +25,7 @@
#include <linux/if_ether.h>
#include <linux/ip.h>
#include <linux/prefetch.h>
#include <linux/if_vlan.h>

#include "bnad.h"
#include "bna.h"
Expand Down Expand Up @@ -514,24 +516,16 @@ bnad_poll_cq(struct bnad *bnad, struct bna_ccb *ccb, int budget)
rcb->rxq->rx_bytes += skb->len;
skb->protocol = eth_type_trans(skb, bnad->netdev);

if (bnad->vlan_grp && (flags & BNA_CQ_EF_VLAN)) {
struct bnad_rx_ctrl *rx_ctrl =
(struct bnad_rx_ctrl *)ccb->ctrl;
if (skb->ip_summed == CHECKSUM_UNNECESSARY)
vlan_gro_receive(&rx_ctrl->napi, bnad->vlan_grp,
ntohs(cmpl->vlan_tag), skb);
else
vlan_hwaccel_receive_skb(skb,
bnad->vlan_grp,
ntohs(cmpl->vlan_tag));

} else { /* Not VLAN tagged/stripped */
struct bnad_rx_ctrl *rx_ctrl =
(struct bnad_rx_ctrl *)ccb->ctrl;
if (skb->ip_summed == CHECKSUM_UNNECESSARY)
napi_gro_receive(&rx_ctrl->napi, skb);
else
netif_receive_skb(skb);
if (flags & BNA_CQ_EF_VLAN)
__vlan_hwaccel_put_tag(skb, ntohs(cmpl->vlan_tag));

if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
struct bnad_rx_ctrl *rx_ctrl;

rx_ctrl = (struct bnad_rx_ctrl *) ccb->ctrl;
napi_gro_receive(&rx_ctrl->napi, skb);
} else {
netif_receive_skb(skb);
}

next:
Expand Down Expand Up @@ -1981,19 +1975,14 @@ bnad_enable_default_bcast(struct bnad *bnad)
static void
bnad_restore_vlans(struct bnad *bnad, u32 rx_id)
{
u16 vlan_id;
u16 vid;
unsigned long flags;

if (!bnad->vlan_grp)
return;

BUG_ON(!(VLAN_N_VID == (BFI_MAX_VLAN + 1)));

for (vlan_id = 0; vlan_id < VLAN_N_VID; vlan_id++) {
if (!vlan_group_get_device(bnad->vlan_grp, vlan_id))
continue;
for_each_set_bit(vid, bnad->active_vlans, VLAN_N_VID) {
spin_lock_irqsave(&bnad->bna_lock, flags);
bna_rx_vlan_add(bnad->rx_info[rx_id].rx, vlan_id);
bna_rx_vlan_add(bnad->rx_info[rx_id].rx, vid);
spin_unlock_irqrestore(&bnad->bna_lock, flags);
}
}
Expand Down Expand Up @@ -2795,17 +2784,6 @@ bnad_change_mtu(struct net_device *netdev, int new_mtu)
return err;
}

static void
bnad_vlan_rx_register(struct net_device *netdev,
struct vlan_group *vlan_grp)
{
struct bnad *bnad = netdev_priv(netdev);

mutex_lock(&bnad->conf_mutex);
bnad->vlan_grp = vlan_grp;
mutex_unlock(&bnad->conf_mutex);
}

static void
bnad_vlan_rx_add_vid(struct net_device *netdev,
unsigned short vid)
Expand All @@ -2820,6 +2798,7 @@ bnad_vlan_rx_add_vid(struct net_device *netdev,

spin_lock_irqsave(&bnad->bna_lock, flags);
bna_rx_vlan_add(bnad->rx_info[0].rx, vid);
set_bit(vid, bnad->active_vlans);
spin_unlock_irqrestore(&bnad->bna_lock, flags);

mutex_unlock(&bnad->conf_mutex);
Expand All @@ -2838,6 +2817,7 @@ bnad_vlan_rx_kill_vid(struct net_device *netdev,
mutex_lock(&bnad->conf_mutex);

spin_lock_irqsave(&bnad->bna_lock, flags);
clear_bit(vid, bnad->active_vlans);
bna_rx_vlan_del(bnad->rx_info[0].rx, vid);
spin_unlock_irqrestore(&bnad->bna_lock, flags);

Expand Down Expand Up @@ -2887,7 +2867,6 @@ static const struct net_device_ops bnad_netdev_ops = {
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = bnad_set_mac_address,
.ndo_change_mtu = bnad_change_mtu,
.ndo_vlan_rx_register = bnad_vlan_rx_register,
.ndo_vlan_rx_add_vid = bnad_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = bnad_vlan_rx_kill_vid,
#ifdef CONFIG_NET_POLL_CONTROLLER
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/bna/bnad.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/etherdevice.h>
#include <linux/mutex.h>
#include <linux/firmware.h>
#include <linux/if_vlan.h>

/* Fix for IA64 */
#include <asm/checksum.h>
Expand Down Expand Up @@ -216,7 +217,7 @@ struct bnad {
struct bnad_tx_info tx_info[BNAD_MAX_TXS];
struct bnad_rx_info rx_info[BNAD_MAX_RXS];

struct vlan_group *vlan_grp;
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
/*
* These q numbers are global only because
* they are used to calculate MSIx vectors.
Expand Down

0 comments on commit f859d7c

Please sign in to comment.