230 likes | 408 Views
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
E N D
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 28 27 26 25 24 23 22 21 20 19 18 17 16 PHY RST VME R =0 TFCE RFCE RST R =0 R =0 R =0 R =0 R =0 ADV D3 WUC R =0 D/UD status R =0 R =0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 R =0 R =0 R =0 FRC DPLX FRC SPD R =0 SPEED R =0 S L U R =0 R =0 R =1 GIO M D 0 0 R =0 F D 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 Enable FRCSPD = Force Speed RST = Device Reset TFCE = Tx Flow-Control Enable FRCDPLX = Force Duplex 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 0 0 0 0 8 1 0 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 SPECIAL CKSUM START STATUS CMD CKSUM OFFSET LENGTH 7 6 5 4 3 2 1 0 The VLAN Tag goes here I D E V L E D E X T 0 R S I C I F C S E O P And the VLE-bit (VLAN Packet Enable) is set in the descriptor’s command-field
Receive Control (0x0100) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 R =0 0 FLXBUF 0 SE CRC BSEX R =0 PMCF DPF R =0 CFI CFI EN VFE BSIZE 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 B A M R =0 MO DTYP RDMTS I L O S LBM S L U LPE MPE UPE 0 0 SBP E N R =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 ERRORS STATUS CHECKSUM LENGTH 7 6 5 4 3 2 1 0 P I F I P C S T T P C S U D P C S V P I X S M E O P D D The VP-bit (VLAN Packet) will be set in the descriptor status byte if the received packet’s Type matched the VET register-value And the VLAN Tag will be placed here
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 “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: 0x0234 0 1 2 3 4 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 The ‘blue’ VLAN anchor01 anchor02 anchor11 anchor12 Version with 0x0234 as tag 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?