1 --- linux.orig/drivers/net/3c59x.c Sun Sep 30 21:26:06 2001
2 +++ linux/drivers/net/3c59x.c Wed Oct 24 21:52:10 2001
4 code size of a per-interface flag is not worthwhile. */
5 static char mii_preamble_required;
7 +/* The Ethernet Type used for 802.1q tagged frames */
8 +#define VLAN_ETHER_TYPE 0x8100
10 #define PFX DRV_NAME ": "
16 enum Window3 { /* Window 3: MAC/config bits. */
17 - Wn3_Config=0, Wn3_MAC_Ctrl=6, Wn3_Options=8,
18 + Wn3_Config=0, Wn3_MaxPktSize=4, Wn3_MAC_Ctrl=6, Wn3_Options=8,
21 #define BFEXT(value, offset, bitcount) \
23 Media_LnkBeat = 0x0800,
25 enum Window7 { /* Window 7: Bus Master control. */
26 - Wn7_MasterAddr = 0, Wn7_MasterLen = 6, Wn7_MasterStatus = 12,
27 + Wn7_MasterAddr = 0, Wn7_VlanEtherType=4, Wn7_MasterLen = 6,
28 + Wn7_MasterStatus = 12,
30 /* Boomerang bus master control registers. */
33 pm_state_valid:1, /* power_state[] has sane contents */
36 - must_free_region:1; /* Flag: if zero, Cardbus owns the I/O region */
37 + must_free_region:1, /* Flag: if zero, Cardbus owns the I/O region */
38 + large_frames:1; /* accept large frames */
43 static void vortex_tx_timeout(struct net_device *dev);
44 static void acpi_set_WOL(struct net_device *dev);
45 static struct ethtool_ops vortex_ethtool_ops;
46 +#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
47 +static void set_8021q_mode(struct net_device *dev, int enable);
50 /* This driver uses 'options' to pass the media type, full-duplex flag, etc. */
51 /* Option count limit only -- unlimited interfaces are supported. */
53 dev->base_addr = ioaddr;
56 + vp->large_frames = mtu > 1500;
57 vp->drv_flags = vci->drv_flags;
58 vp->has_nway = (vci->drv_flags & HAS_NWAY) ? 1 : 0;
59 vp->io_size = vci->io_size;
62 /* Set the full-duplex bit. */
63 outw( ((vp->info1 & 0x8000) || vp->full_duplex ? 0x20 : 0) |
64 - (dev->mtu > 1500 ? 0x40 : 0) |
65 + (vp->large_frames ? 0x40 : 0) |
66 ((vp->full_duplex && vp->flow_ctrl && vp->partner_flow_ctrl) ? 0x100 : 0),
67 ioaddr + Wn3_MAC_Ctrl);
69 @@ -1545,6 +1554,10 @@
71 /* Set receiver mode: presumably accept b-case and phys addr only. */
73 +#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
74 + /* enable 802.1q tagged frames */
75 + set_8021q_mode(dev, 1);
77 outw(StatsEnable, ioaddr + EL3_CMD); /* Turn on statistics. */
79 // issue_and_wait(dev, SetTxStart|0x07ff);
81 /* Set the full-duplex bit. */
83 outw( (vp->full_duplex ? 0x20 : 0) |
84 - (dev->mtu > 1500 ? 0x40 : 0) |
85 + (vp->large_frames ? 0x40 : 0) |
86 ((vp->full_duplex && vp->flow_ctrl && vp->partner_flow_ctrl) ? 0x100 : 0),
87 ioaddr + Wn3_MAC_Ctrl);
89 @@ -1900,6 +1913,10 @@
90 issue_and_wait(dev, RxReset|0x07);
91 /* Set the Rx filter to the current state. */
93 +#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
94 + /* enable 802.1q VLAN tagged frames */
95 + set_8021q_mode(dev, 1);
97 outw(RxEnable, ioaddr + EL3_CMD); /* Re-enable the receiver. */
98 outw(AckIntr | HostError, ioaddr + EL3_CMD);
100 @@ -2497,6 +2514,11 @@
101 outw(RxDisable, ioaddr + EL3_CMD);
102 outw(TxDisable, ioaddr + EL3_CMD);
104 +#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
105 + /* Disable receiving 802.1q tagged frames */
106 + set_8021q_mode(dev, 0);
109 if (dev->if_port == XCVR_10base2)
110 /* Turn off thinnet power. Green! */
111 outw(StopCoax, ioaddr + EL3_CMD);
112 @@ -2760,6 +2782,50 @@
114 outw(new_mode, ioaddr + EL3_CMD);
117 +#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
118 +/* Setup the card so that it can receive frames with an 802.1q VLAN tag.
119 + Note that this must be done after each RxReset due to some backwards
120 + compatibility logic in the Cyclone and Tornado ASICs */
121 +static void set_8021q_mode(struct net_device *dev, int enable)
123 + struct vortex_private *vp = (struct vortex_private *)dev->priv;
124 + long ioaddr = dev->base_addr;
125 + int old_window = inw(ioaddr + EL3_CMD);
128 + if (vp->drv_flags&IS_CYCLONE || vp->drv_flags&IS_TORNADO) {
129 + /* cyclone and tornado chipsets can recognize 802.1q
130 + * tagged frames and treat them correctly */
132 + int max_pkt_size = dev->mtu+14; /* MTU+Ethernet header */
134 + max_pkt_size += 4; /* 802.1Q VLAN tag */
137 + outw(max_pkt_size, ioaddr+Wn3_MaxPktSize);
139 + /* set VlanEtherType to let the hardware checksumming
140 + treat tagged frames correctly */
142 + outw(VLAN_ETHER_TYPE, ioaddr+Wn7_VlanEtherType);
144 + /* on older cards we have to enable large frames */
146 + vp->large_frames = dev->mtu > 1500 || enable;
149 + mac_ctrl = inw(ioaddr+Wn3_MAC_Ctrl);
150 + if (vp->large_frames)
154 + outw(mac_ctrl, ioaddr+Wn3_MAC_Ctrl);
157 + EL3WINDOW(old_window);
161 /* MII transceiver control section.
162 Read and write the MII registers using software-generated serial