From: Shmuel Hen <shmulik.hen@intel.com>
To: "David S. Miller" <davem@redhat.com>, "Jeff Garzik" <jgarzik@pobox.com>
Cc: "linux-netdev" <netdev@oss.sgi.com>,
"bonding-devel" <bonding-devel@lists.sourceforge.net>
Subject: [PATCH 2/2] [8021q 2.4] Use VLAN tag set functionality in 8021q module
Date: Thu, 19 Feb 2004 12:13:50 +0200 [thread overview]
Message-ID: <200402191213.51683.shmulik.hen@intel.com> (raw)
Now, that 2.4.25 is out, I'm resending the enhancements for VLAN over bonding.
Tested for patch application and compilation against linux-2.4.25.
Summary:
Make the regular/HW accelerated xmit functions in the 8021q module
use the new set VLAN tag functionality to reduce code duplication.
--
| Shmulik Hen Advanced Network Services |
| Israel Design Center, Jerusalem |
| LAN Access Division, Platform Networking |
| Intel Communications Group, Intel corp. |
diff -Nuarp a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
--- a/net/8021q/vlan_dev.c Wed Jan 21 16:55:02 2004
+++ b/net/8021q/vlan_dev.c Wed Jan 21 16:55:04 2004
@@ -446,6 +446,7 @@ int vlan_dev_hard_start_xmit(struct sk_b
*/
if (veth->h_vlan_proto != __constant_htons(ETH_P_8021Q)) {
+ int orig_headroom = skb_headroom(skb);
unsigned short veth_TCI;
/* This is not a VLAN frame...but we can fix that! */
@@ -455,33 +456,7 @@ int vlan_dev_hard_start_xmit(struct sk_b
printk(VLAN_DBG "%s: proto to encap: 0x%hx (hbo)\n",
__FUNCTION__, htons(veth->h_vlan_proto));
#endif
-
- if (skb_headroom(skb) < VLAN_HLEN) {
- struct sk_buff *sk_tmp = skb;
- skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN);
- kfree_skb(sk_tmp);
- if (skb == NULL) {
- stats->tx_dropped++;
- return 0;
- }
- VLAN_DEV_INFO(dev)->cnt_inc_headroom_on_tx++;
- } else {
- if (!(skb = skb_unshare(skb, GFP_ATOMIC))) {
- printk(KERN_ERR "vlan: failed to unshare skbuff\n");
- stats->tx_dropped++;
- return 0;
- }
- }
- veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
-
- /* Move the mac addresses to the beginning of the new header. */
- memmove(skb->data, skb->data + VLAN_HLEN, 12);
-
- /* first, the ethernet type */
- /* put_unaligned(__constant_htons(ETH_P_8021Q), &veth->h_vlan_proto); */
- veth->h_vlan_proto = __constant_htons(ETH_P_8021Q);
-
- /* Now, construct the second two bytes. This field looks something
+ /* Construct the second two bytes. This field looks something
* like:
* usr_priority: 3 bits (high bits)
* CFI 1 bit
@@ -490,10 +465,16 @@ int vlan_dev_hard_start_xmit(struct sk_b
veth_TCI = VLAN_DEV_INFO(dev)->vlan_id;
veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
- veth->h_vlan_TCI = htons(veth_TCI);
- }
+ skb = __vlan_put_tag(skb, veth_TCI);
+ if (!skb) {
+ stats->tx_dropped++;
+ return 0;
+ }
- skb->dev = VLAN_DEV_INFO(dev)->real_dev;
+ if (orig_headroom < VLAN_HLEN) {
+ VLAN_DEV_INFO(dev)->cnt_inc_headroom_on_tx++;
+ }
+ }
#ifdef VLAN_DEBUG
printk(VLAN_DBG "%s: about to send skb: %p to dev: %s\n",
@@ -507,6 +488,7 @@ int vlan_dev_hard_start_xmit(struct sk_b
stats->tx_packets++; /* for statics only */
stats->tx_bytes += skb->len;
+ skb->dev = VLAN_DEV_INFO(dev)->real_dev;
dev_queue_xmit(skb);
return 0;
@@ -515,17 +497,22 @@ int vlan_dev_hard_start_xmit(struct sk_b
int vlan_dev_hwaccel_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct net_device_stats *stats = vlan_dev_get_stats(dev);
- struct vlan_skb_tx_cookie *cookie;
+ unsigned short veth_TCI;
+
+ /* Construct the second two bytes. This field looks something
+ * like:
+ * usr_priority: 3 bits (high bits)
+ * CFI 1 bit
+ * VLAN ID 12 bits (low bits)
+ */
+ veth_TCI = VLAN_DEV_INFO(dev)->vlan_id;
+ veth_TCI |= vlan_dev_get_egress_qos_mask(dev, skb);
+ skb = __vlan_hwaccel_put_tag(skb, veth_TCI);
stats->tx_packets++;
stats->tx_bytes += skb->len;
skb->dev = VLAN_DEV_INFO(dev)->real_dev;
- cookie = VLAN_TX_SKB_CB(skb);
- cookie->magic = VLAN_TX_COOKIE_MAGIC;
- cookie->vlan_tag = (VLAN_DEV_INFO(dev)->vlan_id |
- vlan_dev_get_egress_qos_mask(dev, skb));
-
dev_queue_xmit(skb);
return 0;
next reply other threads:[~2004-02-19 10:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-19 10:13 Shmuel Hen [this message]
2004-02-19 18:19 ` [PATCH 2/2] [8021q 2.4] Use VLAN tag set functionality in 8021q module David S. Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200402191213.51683.shmulik.hen@intel.com \
--to=shmulik.hen@intel.com \
--cc=bonding-devel@lists.sourceforge.net \
--cc=davem@redhat.com \
--cc=jgarzik@pobox.com \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).