aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Fastabend <john.r.fastabend@intel.com>2010-10-30 10:22:42 -0400
committerDavid S. Miller <davem@davemloft.net>2010-11-15 13:11:40 -0500
commit636e19a34275d7d6fda0fefa965b1e2a715e2b02 (patch)
tree134160c8880adef0d9afc159da22dc577b9fa3c8
parent8f5549f381ced6a255f2c7127b2b3b3b05fdfd6e (diff)
net: consolidate 8021q tagging
Now that VLAN packets are tagged in dev_hard_start_xmit() at the bottom of the stack we no longer need to tag them in the 8021Q module (Except in the !VLAN_FLAG_REORDER_HDR case). This allows the accel path and non accel paths to be consolidated. Here the vlan_tci in the skb is always set and we allow the stack to add the actual tag in dev_hard_start_xmit(). Signed-off-by: John Fastabend <john.r.fastabend@intel.com> Acked-by: Jesse Gross <jesse@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/8021q/vlan.h4
-rw-r--r--net/8021q/vlan_dev.c105
-rw-r--r--net/8021q/vlanproc.c4
3 files changed, 7 insertions, 106 deletions
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index db01b3181fdc..4625ba64dfdc 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -45,8 +45,6 @@ struct vlan_rx_stats {
45 * @real_dev: underlying netdevice 45 * @real_dev: underlying netdevice
46 * @real_dev_addr: address of underlying netdevice 46 * @real_dev_addr: address of underlying netdevice
47 * @dent: proc dir entry 47 * @dent: proc dir entry
48 * @cnt_inc_headroom_on_tx: statistic - number of skb expansions on TX
49 * @cnt_encap_on_xmit: statistic - number of skb encapsulations on TX
50 * @vlan_rx_stats: ptr to percpu rx stats 48 * @vlan_rx_stats: ptr to percpu rx stats
51 */ 49 */
52struct vlan_dev_info { 50struct vlan_dev_info {
@@ -62,8 +60,6 @@ struct vlan_dev_info {
62 unsigned char real_dev_addr[ETH_ALEN]; 60 unsigned char real_dev_addr[ETH_ALEN];
63 61
64 struct proc_dir_entry *dent; 62 struct proc_dir_entry *dent;
65 unsigned long cnt_inc_headroom_on_tx;
66 unsigned long cnt_encap_on_xmit;
67 struct vlan_rx_stats __percpu *vlan_rx_stats; 63 struct vlan_rx_stats __percpu *vlan_rx_stats;
68}; 64};
69 65
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index afb03c5a7adc..f3c9552f6ba8 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -323,24 +323,12 @@ static netdev_tx_t vlan_dev_hard_start_xmit(struct sk_buff *skb,
323 */ 323 */
324 if (veth->h_vlan_proto != htons(ETH_P_8021Q) || 324 if (veth->h_vlan_proto != htons(ETH_P_8021Q) ||
325 vlan_dev_info(dev)->flags & VLAN_FLAG_REORDER_HDR) { 325 vlan_dev_info(dev)->flags & VLAN_FLAG_REORDER_HDR) {
326 unsigned int orig_headroom = skb_headroom(skb);
327 u16 vlan_tci; 326 u16 vlan_tci;
328
329 vlan_dev_info(dev)->cnt_encap_on_xmit++;
330
331 vlan_tci = vlan_dev_info(dev)->vlan_id; 327 vlan_tci = vlan_dev_info(dev)->vlan_id;
332 vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb); 328 vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
333 skb = __vlan_put_tag(skb, vlan_tci); 329 skb = __vlan_hwaccel_put_tag(skb, vlan_tci);
334 if (!skb) {
335 txq->tx_dropped++;
336 return NETDEV_TX_OK;
337 }
338
339 if (orig_headroom < VLAN_HLEN)
340 vlan_dev_info(dev)->cnt_inc_headroom_on_tx++;
341 } 330 }
342 331
343
344 skb_set_dev(skb, vlan_dev_info(dev)->real_dev); 332 skb_set_dev(skb, vlan_dev_info(dev)->real_dev);
345 len = skb->len; 333 len = skb->len;
346 ret = dev_queue_xmit(skb); 334 ret = dev_queue_xmit(skb);
@@ -354,32 +342,6 @@ static netdev_tx_t vlan_dev_hard_start_xmit(struct sk_buff *skb,
354 return ret; 342 return ret;
355} 343}
356 344
357static netdev_tx_t vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb,
358 struct net_device *dev)
359{
360 int i = skb_get_queue_mapping(skb);
361 struct netdev_queue *txq = netdev_get_tx_queue(dev, i);
362 u16 vlan_tci;
363 unsigned int len;
364 int ret;
365
366 vlan_tci = vlan_dev_info(dev)->vlan_id;
367 vlan_tci |= vlan_dev_get_egress_qos_mask(dev, skb);
368 skb = __vlan_hwaccel_put_tag(skb, vlan_tci);
369
370 skb->dev = vlan_dev_info(dev)->real_dev;
371 len = skb->len;
372 ret = dev_queue_xmit(skb);
373
374 if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) {
375 txq->tx_packets++;
376 txq->tx_bytes += len;
377 } else
378 txq->tx_dropped++;
379
380 return ret;
381}
382
383static u16 vlan_dev_select_queue(struct net_device *dev, struct sk_buff *skb) 345static u16 vlan_dev_select_queue(struct net_device *dev, struct sk_buff *skb)
384{ 346{
385 struct net_device *rdev = vlan_dev_info(dev)->real_dev; 347 struct net_device *rdev = vlan_dev_info(dev)->real_dev;
@@ -716,8 +678,7 @@ static const struct header_ops vlan_header_ops = {
716 .parse = eth_header_parse, 678 .parse = eth_header_parse,
717}; 679};
718 680
719static const struct net_device_ops vlan_netdev_ops, vlan_netdev_accel_ops, 681static const struct net_device_ops vlan_netdev_ops, vlan_netdev_ops_sq;
720 vlan_netdev_ops_sq, vlan_netdev_accel_ops_sq;
721 682
722static int vlan_dev_init(struct net_device *dev) 683static int vlan_dev_init(struct net_device *dev)
723{ 684{
@@ -752,19 +713,16 @@ static int vlan_dev_init(struct net_device *dev)
752 if (real_dev->features & NETIF_F_HW_VLAN_TX) { 713 if (real_dev->features & NETIF_F_HW_VLAN_TX) {
753 dev->header_ops = real_dev->header_ops; 714 dev->header_ops = real_dev->header_ops;
754 dev->hard_header_len = real_dev->hard_header_len; 715 dev->hard_header_len = real_dev->hard_header_len;
755 if (real_dev->netdev_ops->ndo_select_queue)
756 dev->netdev_ops = &vlan_netdev_accel_ops_sq;
757 else
758 dev->netdev_ops = &vlan_netdev_accel_ops;
759 } else { 716 } else {
760 dev->header_ops = &vlan_header_ops; 717 dev->header_ops = &vlan_header_ops;
761 dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN; 718 dev->hard_header_len = real_dev->hard_header_len + VLAN_HLEN;
762 if (real_dev->netdev_ops->ndo_select_queue)
763 dev->netdev_ops = &vlan_netdev_ops_sq;
764 else
765 dev->netdev_ops = &vlan_netdev_ops;
766 } 719 }
767 720
721 if (real_dev->netdev_ops->ndo_select_queue)
722 dev->netdev_ops = &vlan_netdev_ops_sq;
723 else
724 dev->netdev_ops = &vlan_netdev_ops;
725
768 if (is_vlan_dev(real_dev)) 726 if (is_vlan_dev(real_dev))
769 subclass = 1; 727 subclass = 1;
770 728
@@ -905,30 +863,6 @@ static const struct net_device_ops vlan_netdev_ops = {
905#endif 863#endif
906}; 864};
907 865
908static const struct net_device_ops vlan_netdev_accel_ops = {
909 .ndo_change_mtu = vlan_dev_change_mtu,
910 .ndo_init = vlan_dev_init,
911 .ndo_uninit = vlan_dev_uninit,
912 .ndo_open = vlan_dev_open,
913 .ndo_stop = vlan_dev_stop,
914 .ndo_start_xmit = vlan_dev_hwaccel_hard_start_xmit,
915 .ndo_validate_addr = eth_validate_addr,
916 .ndo_set_mac_address = vlan_dev_set_mac_address,
917 .ndo_set_rx_mode = vlan_dev_set_rx_mode,
918 .ndo_set_multicast_list = vlan_dev_set_rx_mode,
919 .ndo_change_rx_flags = vlan_dev_change_rx_flags,
920 .ndo_do_ioctl = vlan_dev_ioctl,
921 .ndo_neigh_setup = vlan_dev_neigh_setup,
922 .ndo_get_stats64 = vlan_dev_get_stats64,
923#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
924 .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup,
925 .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done,
926 .ndo_fcoe_enable = vlan_dev_fcoe_enable,
927 .ndo_fcoe_disable = vlan_dev_fcoe_disable,
928 .ndo_fcoe_get_wwn = vlan_dev_fcoe_get_wwn,
929#endif
930};
931
932static const struct net_device_ops vlan_netdev_ops_sq = { 866static const struct net_device_ops vlan_netdev_ops_sq = {
933 .ndo_select_queue = vlan_dev_select_queue, 867 .ndo_select_queue = vlan_dev_select_queue,
934 .ndo_change_mtu = vlan_dev_change_mtu, 868 .ndo_change_mtu = vlan_dev_change_mtu,
@@ -954,31 +888,6 @@ static const struct net_device_ops vlan_netdev_ops_sq = {
954#endif 888#endif
955}; 889};
956 890
957static const struct net_device_ops vlan_netdev_accel_ops_sq = {
958 .ndo_select_queue = vlan_dev_select_queue,
959 .ndo_change_mtu = vlan_dev_change_mtu,
960 .ndo_init = vlan_dev_init,
961 .ndo_uninit = vlan_dev_uninit,
962 .ndo_open = vlan_dev_open,
963 .ndo_stop = vlan_dev_stop,
964 .ndo_start_xmit = vlan_dev_hwaccel_hard_start_xmit,
965 .ndo_validate_addr = eth_validate_addr,
966 .ndo_set_mac_address = vlan_dev_set_mac_address,
967 .ndo_set_rx_mode = vlan_dev_set_rx_mode,
968 .ndo_set_multicast_list = vlan_dev_set_rx_mode,
969 .ndo_change_rx_flags = vlan_dev_change_rx_flags,
970 .ndo_do_ioctl = vlan_dev_ioctl,
971 .ndo_neigh_setup = vlan_dev_neigh_setup,
972 .ndo_get_stats64 = vlan_dev_get_stats64,
973#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
974 .ndo_fcoe_ddp_setup = vlan_dev_fcoe_ddp_setup,
975 .ndo_fcoe_ddp_done = vlan_dev_fcoe_ddp_done,
976 .ndo_fcoe_enable = vlan_dev_fcoe_enable,
977 .ndo_fcoe_disable = vlan_dev_fcoe_disable,
978 .ndo_fcoe_get_wwn = vlan_dev_fcoe_get_wwn,
979#endif
980};
981
982void vlan_setup(struct net_device *dev) 891void vlan_setup(struct net_device *dev)
983{ 892{
984 ether_setup(dev); 893 ether_setup(dev);
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c
index 80e280f56686..8a64db19b8a5 100644
--- a/net/8021q/vlanproc.c
+++ b/net/8021q/vlanproc.c
@@ -299,10 +299,6 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
299 seq_puts(seq, "\n"); 299 seq_puts(seq, "\n");
300 seq_printf(seq, fmt64, "total frames transmitted", stats->tx_packets); 300 seq_printf(seq, fmt64, "total frames transmitted", stats->tx_packets);
301 seq_printf(seq, fmt64, "total bytes transmitted", stats->tx_bytes); 301 seq_printf(seq, fmt64, "total bytes transmitted", stats->tx_bytes);
302 seq_printf(seq, fmt, "total headroom inc",
303 dev_info->cnt_inc_headroom_on_tx);
304 seq_printf(seq, fmt, "total encap on xmit",
305 dev_info->cnt_encap_on_xmit);
306 seq_printf(seq, "Device: %s", dev_info->real_dev->name); 302 seq_printf(seq, "Device: %s", dev_info->real_dev->name);
307 /* now show all PRIORITY mappings relating to this VLAN */ 303 /* now show all PRIORITY mappings relating to this VLAN */
308 seq_printf(seq, "\nINGRESS priority mappings: " 304 seq_printf(seq, "\nINGRESS priority mappings: "