Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fix vlan in 8139cp on big-endian

Layout of opts2 is
: MSB(vlan_tag) : LSB(vlan_tag) : flags : 0 :
regardless of the host endianness. On little-endian
the current code ends up with the right values, but
on big-endian it blows. In r8169.c the same bug
had been fixed in commit d35da12a40426184b1d0844104b1d464753eba19
(r8169: endianness fixes).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jeff Garzik <jeff@garzik.org>

authored by

Al Viro and committed by
David S. Miller
cf983019 d3bb52b0

+5 -5
+5 -5
drivers/net/8139cp.c
··· 78 78 #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) 79 79 #define CP_VLAN_TAG_USED 1 80 80 #define CP_VLAN_TX_TAG(tx_desc,vlan_tag_value) \ 81 - do { (tx_desc)->opts2 = (vlan_tag_value); } while (0) 81 + do { (tx_desc)->opts2 = cpu_to_le32(vlan_tag_value); } while (0) 82 82 #else 83 83 #define CP_VLAN_TAG_USED 0 84 84 #define CP_VLAN_TX_TAG(tx_desc,vlan_tag_value) \ ··· 304 304 305 305 struct cp_desc { 306 306 __le32 opts1; 307 - u32 opts2; 307 + __le32 opts2; 308 308 __le64 addr; 309 309 }; 310 310 ··· 462 462 cp->dev->last_rx = jiffies; 463 463 464 464 #if CP_VLAN_TAG_USED 465 - if (cp->vlgrp && (desc->opts2 & RxVlanTagged)) { 465 + if (cp->vlgrp && (desc->opts2 & cpu_to_le32(RxVlanTagged))) { 466 466 vlan_hwaccel_receive_skb(skb, cp->vlgrp, 467 - be16_to_cpu(desc->opts2 & 0xffff)); 467 + swab16(le32_to_cpu(desc->opts2) & 0xffff)); 468 468 } else 469 469 #endif 470 470 netif_receive_skb(skb); ··· 765 765 766 766 #if CP_VLAN_TAG_USED 767 767 if (cp->vlgrp && vlan_tx_tag_present(skb)) 768 - vlan_tag = TxVlanTag | cpu_to_be16(vlan_tx_tag_get(skb)); 768 + vlan_tag = TxVlanTag | swab16(vlan_tx_tag_get(skb)); 769 769 #endif 770 770 771 771 entry = cp->tx_head;