aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/orinoco.c
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2006-04-07 04:10:45 -0400
committerJohn W. Linville <linville@tuxdriver.com>2006-04-24 16:15:51 -0400
commita28dc81dcd9ca9a451bfcab0a2351b0b07146759 (patch)
tree6f9e4b754807e3c81c99879dabd13a422a785327 /drivers/net/wireless/orinoco.c
parent470e2aa6dbdd2c7eb6562ae365a17a627f7070e8 (diff)
[PATCH] orinoco: simplify 802.3 encapsulation code
Use skb_pull() to strip the addresses from the original packet. Don't strip protocol bytes. Signed-off-by: Pavel Roskin <proski@gnu.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/orinoco.c')
-rw-r--r--drivers/net/wireless/orinoco.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index e7d06b90afe2..4d6373814b93 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -421,9 +421,8 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
421 hermes_t *hw = &priv->hw; 421 hermes_t *hw = &priv->hw;
422 int err = 0; 422 int err = 0;
423 u16 txfid = priv->txfid; 423 u16 txfid = priv->txfid;
424 char *p;
425 struct ethhdr *eh; 424 struct ethhdr *eh;
426 int data_len, data_off; 425 int data_off;
427 struct hermes_tx_descriptor desc; 426 struct hermes_tx_descriptor desc;
428 unsigned long flags; 427 unsigned long flags;
429 428
@@ -453,8 +452,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
453 } 452 }
454 453
455 /* Check packet length */ 454 /* Check packet length */
456 data_len = skb->len; 455 if (skb->len < ETH_HLEN)
457 if (data_len < ETH_HLEN)
458 goto drop; 456 goto drop;
459 457
460 eh = (struct ethhdr *)skb->data; 458 eh = (struct ethhdr *)skb->data;
@@ -477,22 +475,22 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
477 475
478 /* Encapsulate Ethernet-II frames */ 476 /* Encapsulate Ethernet-II frames */
479 if (ntohs(eh->h_proto) > ETH_DATA_LEN) { /* Ethernet-II frame */ 477 if (ntohs(eh->h_proto) > ETH_DATA_LEN) { /* Ethernet-II frame */
480 struct header_struct hdr; 478 struct header_struct {
481 data_len = skb->len - ETH_HLEN; 479 struct ethhdr eth; /* 802.3 header */
482 data_off = HERMES_802_3_OFFSET + sizeof(hdr); 480 u8 encap[6]; /* 802.2 header */
483 p = skb->data + ETH_HLEN; 481 } __attribute__ ((packed)) hdr;
484 482
485 /* 802.3 header */ 483 /* Strip destination and source from the data */
486 memcpy(hdr.dest, eh->h_dest, ETH_ALEN); 484 skb_pull(skb, 2 * ETH_ALEN);
487 memcpy(hdr.src, eh->h_source, ETH_ALEN); 485 data_off = HERMES_802_2_OFFSET + sizeof(encaps_hdr);
488 hdr.len = htons(data_len + ENCAPS_OVERHEAD); 486
489 487 /* And move them to a separate header */
490 /* 802.2 header */ 488 memcpy(&hdr.eth, eh, 2 * ETH_ALEN);
491 memcpy(&hdr.dsap, &encaps_hdr, sizeof(encaps_hdr)); 489 hdr.eth.h_proto = htons(sizeof(encaps_hdr) + skb->len);
492 490 memcpy(hdr.encap, encaps_hdr, sizeof(encaps_hdr));
493 hdr.ethertype = eh->h_proto; 491
494 err = hermes_bap_pwrite(hw, USER_BAP, &hdr, sizeof(hdr), 492 err = hermes_bap_pwrite(hw, USER_BAP, &hdr, sizeof(hdr),
495 txfid, HERMES_802_3_OFFSET); 493 txfid, HERMES_802_3_OFFSET);
496 if (err) { 494 if (err) {
497 if (net_ratelimit()) 495 if (net_ratelimit())
498 printk(KERN_ERR "%s: Error %d writing packet " 496 printk(KERN_ERR "%s: Error %d writing packet "
@@ -500,12 +498,10 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
500 goto busy; 498 goto busy;
501 } 499 }
502 } else { /* IEEE 802.3 frame */ 500 } else { /* IEEE 802.3 frame */
503 data_len = skb->len;
504 data_off = HERMES_802_3_OFFSET; 501 data_off = HERMES_802_3_OFFSET;
505 p = skb->data;
506 } 502 }
507 503
508 err = hermes_bap_pwrite(hw, USER_BAP, p, data_len, 504 err = hermes_bap_pwrite(hw, USER_BAP, skb->data, skb->len,
509 txfid, data_off); 505 txfid, data_off);
510 if (err) { 506 if (err) {
511 printk(KERN_ERR "%s: Error %d writing packet to BAP\n", 507 printk(KERN_ERR "%s: Error %d writing packet to BAP\n",
@@ -527,7 +523,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
527 } 523 }
528 524
529 dev->trans_start = jiffies; 525 dev->trans_start = jiffies;
530 stats->tx_bytes += data_off + data_len; 526 stats->tx_bytes += data_off + skb->len;
531 goto ok; 527 goto ok;
532 528
533 drop: 529 drop: