Virtual Local Area Networks supports IEEE standard 802.1q for ethernet VLANs

advertisement
Virtual Local Area Networks
A look at how the Intel 82573L nic
supports IEEE standard 802.1q
for ethernet VLANs
What is a LAN?
switched hub
All the workstations and servers which are physically connected
via switches and hubs would comprise the Local Area Network
When a broadcast-packet gets transmitted by ANY station on the
LAN, it gets received by ALL of the other stations on that LAN
Dividing the network traffic
switched hub
switched hub
In order to physically segregate the network traffic -- and reduce the
congestion caused by broadcast-packets going to all the stations -the network manager needs to purchase a separate switched hub.
What is a ‘Virtual’ LAN?
switched hub
Different subsets of the stations belonging to the same physical LAN
can remain logically interconnected, while at the same time being
kept logically separate from stations which do not share membership
in a designated subset – all without the need to buy another switch
IEEE 802.1q
• A standard way for implementing VLANs
was promulgated by the IEEE in 1997, so
nowadays most network controllers would
provide optional built-in hardware support
for VLAN controls based on this standard
• The mechanism involves ‘tagging’ packets
with a small amount of extra information,
then using that information to do ‘filtering’
of ‘tagged’ packets as they are received
Ethernet-frame “tagging”
Standard IEEE 802.3 Ethernet Frame format
preamble SFD DA SA T/L
data
CRC delay
SFD (Start-of-Frame Deliniter)
Extra information is inserted
preamble SFD DA SA TPID
TAG
T/L
data
CRC delay
TPID (Tag Protocol Identifier) = 0x8100
User
priority
CFI
VLAN
identifier
CFI (Canonical Format Indicator) = 0 (for ethernet)
User priority values (802.1p)
User priority
Traffic Type
7 (highest)
Network Management
6
Voice (delay < 10ms)
5
Video (delay < 100ms)
4
Controlled Load
3
Excellent Effort
2
Undefined
1 (lowest)
Background
0
Best Effort
Elements for VLAN support
•
•
•
•
•
•
Device Control register: bit 30 (VME)
Receive Control register: bit 18 (VFE)
VLAN Ether Type register: bits 15..0 (VET)
VLAN Filter-Table Array: 0x5600 – 0x57FF
Fields within the Tx Descriptors
Fields within the Rx Descriptors
Device Control (0x0000)
31
30
29
R
PHY
VME
RST
=0
15
28
27
26
TFCE RFCE RST
14
13
R
R
R
=0
=0
=0
12
25
23
22
21
R
R
R
R
R
=0
=0
=0
=0
=0
11
FRC FRC
DPLX SPD
FD = Full-Duplex
GIOMD = GIO Master Disable
SLU = Set Link Up
FRCSPD = Force Speed
FRCDPLX = Force Duplex
24
10
R
=0
9
SPEED
8
=0
19
ADV
D3
WUC
7
R
20
6
S
L
U
R
=0
5
18
17
D/UD
status
4
R
R
=0
=0
3
R
R
R
=0
=0
=1
16
2
1
0
GIO
M
0
D
R
0=0
F
D
SPEED (00=10Mbps, 01=100Mbps, 10=1000Mbps, 11=reserved)
ADVD3WUP = Advertise Cold Wake Up Capability
D/UD = Dock/Undock status
RFCE = Rx Flow-Control Enable
RST = Device Reset
TFCE = Tx Flow-Control Enable
PHYRST = Phy Reset
VME = VLAN Mode Enable
We must set bit 30 to enable our NIC’s “VLAN mode” operation
82573L
VLAN Ether Type (0x0038)
31
0
0000 8100
This lower 16-bits of this register specifies the value that our network
controller will insert as the 2-byte Tag Protocol Identifier (TPID) field.
(This standard value of 0x8100 will be recognized by other hardware
as signifiying that an ethernet packet is “tagged” for VLAN delivery.)
Legacy Tx Descriptors
BASE_ADDRESS
SPECIAL
The VLAN Tag goes here
CKSUM
STATUS
START
7
6
5
I
D
E
V
L
E
D
E
X
T
CMD
4
0
3
CKSUM
OFFSET
2
R I
S C
1
LENGTH
0
I E
F
O
C
S P
And the VLE-bit (VLAN Packet Enable) is set in the descriptor’s command-field
Receive Control (0x0100)
31
R
=0
30
29
0
28
27
F
0LXBUF
15
B
A
M
14
R
=0
13
MO
26
25
SE
CRC
BSEX
12
24
R
23
22
PMCF
DPF
=0
11
DTYP
10
9
8
RDMTS
21
20
R
CFI
=0
7
6
I
S
L
LBML
O
S
U
19
CFI
EN
5
18
17
BSIZE
VFE
4
16
3
2
LPE MPE UPE SBP
0
1
0
E
R
0N
=0
EN = Receive Enable
DTYP = Descriptor Type
DPF = Discard Pause Frames
SBP = Store Bad Packets
MO = Multicast Offset
PMCF = Pass MAC Control Frames
UPE = Unicast Promiscuous Enable
BAM = Broadcast Accept Mode
BSEX = Buffer Size Extension
MPE = Multicast Promiscuous Enable BSIZE = Receive Buffer Size
SECRC = Strip Ethernet CRC
LPE = Long Packet reception Enable VFE = VLAN Filter Enable
FLXBUF = Flexible Buffer size
LBM = Loopback Mode
CFIEN = Canonical Form Indicator Enable
RDMTS = Rx-Descriptor Minimum Threshold Size
CFI = Canonical Form Indicator bit-value
We must set bit 18 to enable the receive-engine’s “VLAN Filtering” operation
Legacy Rx Descriptors
BASE_ADDRESS
VLAN Tag
And the VLAN Tag
will be placed here
ERRORS STATUS
7
6
5
4
P
I
F
I
P
C
S
T
T
P
C
S
U
D
P
C
S
3
V
P
CHECKSUM
2
1
LENGTH
0
I
E
D
X
O
S
P D
M
The VP-bit (VLAN Packet)
will be set in the descriptor
status byte if the received
packet’s Type matched
the VET register-value
VLAN Filter-Table Array (0x5600)
• The VLAN Filter-Table Array is a series of
128 consecutive 32-bit registers within the
NIC’s i/o-memory address-space which is
used to define a “packet-filtering” bitmap
The VLAN-Identifier value selects a bit within this bitmap
4095
0
00000100000000000…000000000000000000000000100000001000000
‘1’ means that a tagged packet will be accepted
‘0’ means that a tagged packet will be ‘dropped’
The Filter-Table arithmetic
• The 12-bit VLAN Identifier in a packet’s
receive-descriptor functions as a “tablelookup” index into this 4096-bit bitmap:
register_offset = ( vlan_id / 32 ) * 4;
bit_selection = ( vlan_id % 32 );
Our ‘tryvlan.c’ module
• Here’s a ‘drop in’ replacement for our prior
‘nic.c’ character-mode Linux device-driver
• It enables the controller’s VLAN mode for
automatic ‘tagging’ and ‘filtering’ of all the
packets being transmitted and/or received
• Most of the previous code is unmodified
• The relatively few lines that have changed
or been added are marked by an askerick
In-class exercise #1
• Adjust the values stored in the ‘special’
field of the Transmit Descriptors so that
successive descriptors use two different
12-bit values alternately:
0
1
2
3
4
0x0234
0x0567
0x0234
0x0567
...
0x0234
Two ‘tryvlan.c’ versions
• Create two versions of our demo-module,
using your two different ‘special’ values to
setup the VFTA bitmaps, and install these
distinct versions on four different ‘anchor’
machines, like this:
The ‘red’ VLAN
anchor01
anchor02
Version with 0x0234 as tag
The ‘blue’ VLAN
anchor11
anchor12
Version with 0x0567 as tag
In-class exercise #1 (continued)
• Use the Linux ‘echo’ and ‘cat’ commands
to send a succession of broadcast-packets
on the ‘red’ VLAN and on the ‘blue’ VLAN
by writing to the ‘/dev/nic’ device-file with
echo on the odd-numbed anchor-stations
and simultaneously reading from ‘/dev/nic’
with cat on the even-numbered stations
• Which machines receive your broadcasts?
In-class exercise #2
• What happens if you modify your code for
the two ‘tryvlan.c’ revised versions so that
in some of the Transmit Descriptors the
command-byte’s VLE-bit (bit #6) is ‘clear’
rather than being ‘set’?
In-class exercise #3
• What happens if you program the nic’s
VET register with a value other than the
standard VLAN Ether Type of 0x8100?
Download