Unformatted text preview:

Accessing the NICSlide 2Slide 3Role for a ‘device driver’Three x86 address-spacesInterface to PCI Configuration Space82573LOur NIC’s ID numbersNIC’s access mechanismsSlide 10Slide 11Slide 12Reading PCI Configuration DataSlide 14Example: network interfaceSlide 16Linux PCI helper-functionsMechanisms comparedC language hides complexitySeeing through the CSlide 21TimeStamp CounterUsing CLI and STIIn-class exerciseAccessing the NICA look at the mechanisms that software can use to interact with our 82573L network interfacenicTypical NIC hardware TX FIFORX FIFOtransceiver LANcableBUSmain memorypacketbufferCPUNo way to communicateLinux operating system kernel(no knowledge of the NIC)Network interface controller(no knowledge of the OS)HARDWARE SOFTWAREThese components lack a way to interactRole for a ‘device driver’Linux operating system kernel(no knowledge of the NIC)Network interface controller(no knowledge of the OS)HARDWARE SOFTWARE device driver module (knows about both the OS and the NIC)Three x86 address-spacesmemoryspace(4GB)i/o space(64KB)PCIconfigurationspace(16MB)accessed using a large variety of processor instructions (mov, add, or, shr, push, etc.) and virtual-to-physical address-translation accessed only by using the processor’s special ‘in’ and ‘out’ instructions (without any translation of port-addresses) i/o-ports 0x0CF8-0x0CFF dedicated to accessing PCI Configuration SpacereservedInterface to PCI Configuration SpaceCONFADD( 0x0CF8)CONFDAT( 0x0CFC)31 23 16 15 11 10 8 7 2 0ENbus(8-bits)device(5-bits)doubleword (6-bits) function(3-bits)00PCI Configuration Space Address Port (32-bits)PCI Configuration Space Data Port (32-bits)31 0 Enable Configuration Space Mapping (1=yes, 0=no)82573L•Two mechanisms for accessing the NIC:–I/O space (allows booting over the network)–Memory-mapped I/O (available after booting)•Both mechanisms require probing for PCI Configuration Space information (for I/O port-number or memory-mapped address) •Probing requires knowing the device’s IDs (the VENDOR_ID and the DEVICE_ID)Our NIC’s ID numbers•The VENDOR_ID for Intel Corporation:–0x8086 (famous chip-number for IBM-PCs)•The DEVICE_ID for Intel’s 82573L NIC:–0x109A (found in Intel’s documentation p.141)NIC’s access mechanisms•The two ways for accessing our network controller’s ‘control’ and ‘status’ registers are explained in Chapter 13 of the Intel Open Source Programmer’s Reference•This Chapter also includes a detailed list of the names and functional descriptions for the various network interface registers•All are accessed as 32-bit ‘doubewords’PCI Configuration SpacePCI Configuration Space Body(48 doublewords – variable format) 64doublewordsPCI Configuration Space Header(16 doublewords – fixed format)A non-volatile parameter-storage area for each PCI device-functionPCI Configuration HeaderStatusRegisterCommandRegisterDeviceIDVendorIDBISTCacheLineSizeClass CodeClass/SubClass/ProgIFRevisionIDBase Address 0SubsystemDevice IDSubsystemVendor IDCardBus CIS PointerreservedcapabilitiespointerExpansion ROM Base AddressMinimumGrantInterruptPinreservedLatencyTimerHeaderTypeBase Address 1Base Address 2Base Address 3Base Address 4Base Address 5InterruptLineMaximumLatency 31 0 31 016 doublewordsDwords 1 - 0 3 - 2 5 - 4 7 - 6 9 - 811 - 1013 - 1215 - 14reservedInterface to PCI Configuration SpaceCONFADD( 0x0CF8)CONFDAT( 0x0CFC)31 23 16 15 11 10 8 7 2 0ENbus(8-bits)device(5-bits)doubleword (6-bits) function(3-bits)00PCI Configuration Space Address Port (32-bits)PCI Configuration Space Data Port (32-bits)31 0 Enable Configuration Space Mapping (1=yes, 0=no)Reading PCI Configuration Data •Step one: Output the desired longword’s address (bus, device, function, and dword) with bit 31 set to 1 (to enable access) to the Configuration-Space Address-Port•Step two: Read the designated data from the Configuration-Space Data-Port:# read the PCI Header-Type field (byte 2 of dword 3) for bus=0, device=0, function=0movl $0x8000000C, %eax # setup address in EAXmovw $0x0CF8, %dx # setup port-number in DX outl %eax, %dx # output address to portmov $0x0CFC, %dx # setup port-number in DXinl %dx, %eax # input configuration longwordshr $16, %eax # shift word 2 into AL registermovb %al, header_type # store Header Type in variableDemo Program•We created a short Linux utility that searches for and reports all of your system’s PCI devices •It’s named “pciprobe.cpp” on our CS686 website•It uses some C++ macros that expand to Intel input/output instructions -- which normally are ‘privileged’ instructions that a Linux application-program is not allowed to execute (segfault!)•Our system administrator (Alex Fedosov) has created a utility (named “iopl3”) that will allow your command-shell to acquire I/O privilegesExample: network interface•We identify the network interface controller in our classroom PC’s by class-code 0x02•The subclass-code 0x00 is for ‘ethernet’•We can identify the NIC from its VENDOR and DEVICE identification-numbers:•VENDOR_ID = 0x8086 (for Intel Corporation)•DEVICE_ID = 0x109A (for 82573L controller)•You can use the ‘grep’ command to search for these numbers in this header-file:</usr/src/linux/include/linux/pci_ids.h>The NIC’s PCI ‘resources’StatusRegisterCommandRegisterDeviceID0x109AVendorID0x8086BISTCacheLineSizeClass CodeClass/SubClass/ProgIFRevisionIDBase Address 0SubsystemDevice IDSubsystemVendor IDCardBus CIS PointerreservedcapabilitiespointerExpansion ROM Base AddressMinimumGrantInterruptPinreservedLatencyTimerHeaderTypeBase Address 1Base Address 2Base Address 3Base Address 4Base Address 5InterruptLineMaximumLatency 31 0 31 016 doublewordsDwords 1 - 0 3 - 2 5 - 4 7 - 6 9 - 811 - 1013 - 1215 - 14Linux PCI helper-functions #include <linux/pci.h> struct pci_dev *devp; unsigned int mmio_base; unsigned int mmio_size; void *io;devp = pci_get_device( VENDOR_ID, DEVICE_ID, NULL );if ( devp == NULL ) return –ENODEV;mmio_base = pci_resource_start( devp, 0 );mmio_size = pci_resource_len( devp, 0 );io = ioremap_nocache( mmio_base, iomm_size );if ( io == NULL ) return –ENOSPC;Mechanisms compared kernel memory-spaceNIC


View Full Document

USF CS 686 - Accessing the NIC

Documents in this Course
Load more
Download Accessing the NIC
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Accessing the NIC and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Accessing the NIC 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?