Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 171607
b: refs/heads/master
c: 9793241
h: refs/heads/master
i:
  171605: badf3a7
  171603: c53163a
  171599: b651e1e
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 18, 2009
1 parent aeef035 commit 2ec250d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d83345adf96bc13a5e360f4649a2e68ef968dec0
refs/heads/master: 9793241fe92f7d9303fb221e43fc598eb065f267
17 changes: 17 additions & 0 deletions trunk/net/8021q/vlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ struct vlan_priority_tci_mapping {
struct vlan_priority_tci_mapping *next;
};


/**
* struct vlan_rx_stats - VLAN percpu rx stats
* @rx_packets: number of received packets
* @rx_bytes: number of received bytes
* @multicast: number of received multicast packets
* @rx_errors: number of errors
*/
struct vlan_rx_stats {
unsigned long rx_packets;
unsigned long rx_bytes;
unsigned long multicast;
unsigned long rx_errors;
};

/**
* struct vlan_dev_info - VLAN private device data
* @nr_ingress_mappings: number of ingress priority mappings
Expand All @@ -29,6 +44,7 @@ struct vlan_priority_tci_mapping {
* @dent: proc dir entry
* @cnt_inc_headroom_on_tx: statistic - number of skb expansions on TX
* @cnt_encap_on_xmit: statistic - number of skb encapsulations on TX
* @vlan_rx_stats: ptr to percpu rx stats
*/
struct vlan_dev_info {
unsigned int nr_ingress_mappings;
Expand All @@ -45,6 +61,7 @@ struct vlan_dev_info {
struct proc_dir_entry *dent;
unsigned long cnt_inc_headroom_on_tx;
unsigned long cnt_encap_on_xmit;
struct vlan_rx_stats *vlan_rx_stats;
};

static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
Expand Down
12 changes: 7 additions & 5 deletions trunk/net/8021q/vlan_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ EXPORT_SYMBOL(__vlan_hwaccel_rx);
int vlan_hwaccel_do_receive(struct sk_buff *skb)
{
struct net_device *dev = skb->dev;
struct net_device_stats *stats;
struct vlan_rx_stats *rx_stats;

skb->dev = vlan_dev_info(dev)->real_dev;
netif_nit_deliver(skb);
Expand All @@ -40,15 +40,17 @@ int vlan_hwaccel_do_receive(struct sk_buff *skb)
skb->priority = vlan_get_ingress_priority(dev, skb->vlan_tci);
skb->vlan_tci = 0;

stats = &dev->stats;
stats->rx_packets++;
stats->rx_bytes += skb->len;
rx_stats = per_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats,
smp_processor_id());

rx_stats->rx_packets++;
rx_stats->rx_bytes += skb->len;

switch (skb->pkt_type) {
case PACKET_BROADCAST:
break;
case PACKET_MULTICAST:
stats->multicast++;
rx_stats->multicast++;
break;
case PACKET_OTHERHOST:
/* Our lower layer thinks this is not local, let's make sure.
Expand Down
47 changes: 41 additions & 6 deletions trunk/net/8021q/vlan_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *ptype, struct net_device *orig_dev)
{
struct vlan_hdr *vhdr;
struct net_device_stats *stats;
struct vlan_rx_stats *rx_stats;
u16 vlan_id;
u16 vlan_tci;

Expand All @@ -163,9 +163,10 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
goto err_unlock;
}

stats = &skb->dev->stats;
stats->rx_packets++;
stats->rx_bytes += skb->len;
rx_stats = per_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats,
smp_processor_id());
rx_stats->rx_packets++;
rx_stats->rx_bytes += skb->len;

skb_pull_rcsum(skb, VLAN_HLEN);

Expand All @@ -180,7 +181,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,
break;

case PACKET_MULTICAST:
stats->multicast++;
rx_stats->multicast++;
break;

case PACKET_OTHERHOST:
Expand All @@ -200,7 +201,7 @@ int vlan_skb_recv(struct sk_buff *skb, struct net_device *dev,

skb = vlan_check_reorder_header(skb);
if (!skb) {
stats->rx_errors++;
rx_stats->rx_errors++;
goto err_unlock;
}

Expand Down Expand Up @@ -731,6 +732,11 @@ static int vlan_dev_init(struct net_device *dev)
subclass = 1;

vlan_dev_set_lockdep_class(dev, subclass);

vlan_dev_info(dev)->vlan_rx_stats = alloc_percpu(struct vlan_rx_stats);
if (!vlan_dev_info(dev)->vlan_rx_stats)
return -ENOMEM;

return 0;
}

Expand All @@ -740,6 +746,8 @@ static void vlan_dev_uninit(struct net_device *dev)
struct vlan_dev_info *vlan = vlan_dev_info(dev);
int i;

free_percpu(vlan->vlan_rx_stats);
vlan->vlan_rx_stats = NULL;
for (i = 0; i < ARRAY_SIZE(vlan->egress_priority_map); i++) {
while ((pm = vlan->egress_priority_map[i]) != NULL) {
vlan->egress_priority_map[i] = pm->next;
Expand Down Expand Up @@ -775,6 +783,31 @@ static u32 vlan_ethtool_get_flags(struct net_device *dev)
return dev_ethtool_get_flags(vlan->real_dev);
}

static struct net_device_stats *vlan_dev_get_stats(struct net_device *dev)
{
struct net_device_stats *stats = &dev->stats;

dev_txq_stats_fold(dev, stats);

if (vlan_dev_info(dev)->vlan_rx_stats) {
struct vlan_rx_stats *p, rx = {0};
int i;

for_each_possible_cpu(i) {
p = per_cpu_ptr(vlan_dev_info(dev)->vlan_rx_stats, i);
rx.rx_packets += p->rx_packets;
rx.rx_bytes += p->rx_bytes;
rx.rx_errors += p->rx_errors;
rx.multicast += p->multicast;
}
stats->rx_packets = rx.rx_packets;
stats->rx_bytes = rx.rx_bytes;
stats->rx_errors = rx.rx_errors;
stats->multicast = rx.multicast;
}
return stats;
}

static const struct ethtool_ops vlan_ethtool_ops = {
.get_settings = vlan_ethtool_get_settings,
.get_drvinfo = vlan_ethtool_get_drvinfo,
Expand All @@ -797,6 +830,7 @@ static const struct net_device_ops vlan_netdev_ops = {
.ndo_change_rx_flags = vlan_dev_change_rx_flags,
.ndo_do_ioctl = vlan_dev_ioctl,
.ndo_neigh_setup = vlan_dev_neigh_setup,
.ndo_get_stats = vlan_dev_get_stats,
#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
.ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup,
.ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done,
Expand All @@ -820,6 +854,7 @@ static const struct net_device_ops vlan_netdev_accel_ops = {
.ndo_change_rx_flags = vlan_dev_change_rx_flags,
.ndo_do_ioctl = vlan_dev_ioctl,
.ndo_neigh_setup = vlan_dev_neigh_setup,
.ndo_get_stats = vlan_dev_get_stats,
#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
.ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup,
.ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done,
Expand Down

0 comments on commit 2ec250d

Please sign in to comment.