Virtual Local Area Networks
description
Transcript of Virtual Local Area Networks
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
Standard IEEE 802.3 Ethernet Frame format
Ethernet-frame “tagging”
preamble SFD DA SA T/L data CRC
preamble SFD DA SA T/L data CRCTPID TAG
Userpriority
CFIVLAN
identifier
delay
delay
TPID (Tag Protocol Identifier) = 0x8100
CFI (Canonical Format Indicator) = 0 (for ethernet)
SFD (Start-of-Frame Deliniter)
Extra information is inserted
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)
PHYRST
VME R=0
TFCE RFCE RST R=0
R=0
R=0
R=0
R=0
ADVD3
WUC
R=0
D/UDstatus
R=0
R=0
R=0
R=0
R=0
FRCDPLX
FRCSPD
R=0
SPEED R=0
SLU
R=0
R=0
R=1
0 0 FD
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
GIOMD
R=0
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
FD = Full-Duplex SPEED (00=10Mbps, 01=100Mbps, 10=1000Mbps, 11=reserved)GIOMD = GIO Master Disable ADVD3WUP = Advertise Cold Wake Up Capability SLU = Set Link Up D/UD = Dock/Undock status RFCE = Rx Flow-Control EnableFRCSPD = Force Speed RST = Device Reset TFCE = Tx Flow-Control EnableFRCDPLX = Force Duplex PHYRST = Phy Reset VME = VLAN Mode Enable
82573LWe must set bit 30 to enable our NIC’s “VLAN mode” operation
VLAN Ether Type (0x0038)
0 0 0 0 8 1 0 0 31 0
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
LENGTHSPECIAL STATUS CMD CKSUMOFFSET
CKSUMSTART
The VLAN Tag goes here IDE
VLE
DEXT
0RS
IC
IFCS
EOP
7 6 5 4 3 2 1 0
And the VLE-bit (VLAN Packet Enable) is set in the descriptor’s command-field
Receive Control (0x0100)
R=0
0 0FLXBUFSE
CRCBSEX R
=0PMCF DPF R
=0CFI
CFIEN
VFE BSIZE
BAM
R=0
MO DTYP RDMTS
ILOS
SLU
LPE UPE 0 0 R=0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SBPEN
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
LBM MPE
EN = Receive Enable DTYP = Descriptor Type DPF = Discard Pause Frames SBP = Store Bad Packets MO = Multicast Offset PMCF = Pass MAC Control FramesUPE = Unicast Promiscuous Enable BAM = Broadcast Accept Mode BSEX = Buffer Size ExtensionMPE = Multicast Promiscuous Enable BSIZE = Receive Buffer Size SECRC = Strip Ethernet CRCLPE = Long Packet reception Enable VFE = VLAN Filter Enable FLXBUF = Flexible Buffer sizeLBM = Loopback Mode CFIEN = Canonical Form Indicator EnableRDMTS = 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
LENGTHVLAN Tag STATUS CHECKSUMERRORS
PIF
IPCS
TTPCS
UDPCS
VP
IXSM
EOP
DD
7 6 5 4 3 2 1 0
And the VLAN Tag will be placed here
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
00000100000000000…000000000000000000000000100000001000000
4095 0
‘1’ means that a tagged packet will be accepted‘0’ means that a tagged packet will be ‘dropped’
The VLAN-Identifier value selects a bit within this bitmap
The Filter-Table arithmetic
• The 12-bit VLAN Identifier in a packet’s receive-descriptor functions as a “table-lookup” 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:
0x023401234
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:
anchor01 anchor02 anchor11 anchor12
Version with 0x0234 as tag Version with 0x0567 as tag
The ‘red’ VLAN The ‘blue’ VLAN
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?