PCIe Hot-Swap Device Driver

Similar documents
... Application Note AN-531. PCI Express System Interconnect Software Architecture. Notes Introduction. System Architecture.

PCI Express System Interconnect Software Architecture for PowerQUICC TM III-based Systems

PCI Express System Interconnect Software Architecture for x86-based Systems. Root Complex. Processor. UP Multi-port PCIe switch DP DP DP

Enabling Multi-peer Support with a Standard-Based PCI Express Multi-ported Switch

System Interconnect Software Programming Interface

PCI-SIG ENGINEERING CHANGE REQUEST

CARRIER-SW-82. Linux Device Driver. IPAC Carrier Version 2.2.x. User Manual. Issue November 2017

Version PEX Recommended only for designs migrating from PEX 8516 please use PEX 8518 for new designs

RIO for Linux v2.2.x

VMware Virtual Infrastructure 3.x Software for Dell PowerEdge Systems. Release Notes. support.dell.com

HP D2600/D2700 Disk Enclosure I/O Module Firmware 0147 Release Notes

Accelerating Storage with NVM Express SSDs and P2PDMA Stephen Bates, PhD Chief Technology Officer

Configuration Request Retry Status (CRS) Handling. Sinan Kaya

PEX 8680, PCI Express Gen 2 Switch, 80 Lanes, 20 Ports

Release Notes CCURDSCC (WC-AD3224-DS)

How to use Linux driver

16-Lane 16-Port PCIe Gen2 System Interconnect Switch with Non-Transparent Bridging

PEX 8636, PCI Express Gen 2 Switch, 36 Lanes, 24 Ports

PCI-SIG ENGINEERING CHANGE NOTICE

Product Release Notes

The Embedded I/O Company TIP700-SW-82 Linux Device Driver User Manual TEWS TECHNOLOGIES GmbH TEWS TECHNOLOGIES LLC

TIP675-SW-82. Linux Device Driver. 48 TTL I/O Lines with Interrupts Version 1.2.x. User Manual. Issue November 2013

Simplify Software Integration for FPGA Accelerators with OPAE

HP StorageWorks Using the QLogic HBA driver for single-path or multi-path failover mode on Linux systems application notes

PCIe driver development for Exynos SoC

Building Customized Linux Kernels A live demonstration. Mark Post August 17, 2004 Session # 9280

PEX 8696, PCI Express Gen 2 Switch, 96 Lanes, 24 Ports

Using the Kernel Security Module Interface

HP StorageWorks Using the QLogic HBA Driver for Single-path or Multi-path Failover Mode on Linux Systems

Product Release Notes

Linux Operating System

The kernel constitutes the core part of the Linux operating system. Kernel duties:

D-Link DGE-528T. Gigabit Ethernet PCI Adapter. User Manual. Rev.5.0

TMS320C62x EVM Interrupt (IRQ) Conflict Resolution

Version PEX 8516

Development of I/O Pass-through: Current Status & the Future. Nov 21, 2008 Yuji Shimada NEC System Technologies, Ltd.

hp StorageWorks Using the QLogic Driver for Single-path or Multi-path Failover Mode on Linux Systems

Express5800/A2040c, A2020c, A2010c, A1040c PCIe Live Error Recovery User s Guide (Release 1.0)

Linux Device Drivers: Case Study of a Storage Controller. Manolis Marazakis FORTH-ICS (CARV)

HP StorageWorks Using the QLogic HBA driver for single-path or multipath failover mode on Linux systems application notes

PCI Bus & Interrupts

PCI-SIG ENGINEERING CHANGE NOTICE

Dual/Quad Channel 4-Port USB 3.0. PCI Express Card

Windows Device Driver and API Reference Manual

Introduction PCI Interface Booting PCI driver registration Other buses. Linux Device Drivers PCI Drivers

Bus Example: Pentium II

OVERDRIVE Quick Start Guide. v.1.0

SIMCom_3G_Linux_Driver_Applica tion Note_V1.00

Outline Background Jaluna-1 Presentation Jaluna-2 Presentation Overview Use Cases Architecture Features Copyright Jaluna SA. All rights reserved

- It must provide a stable programming interfaces that applications can be built upon.

Fibre Channel Adapter and Converged Network Adapter (FCoE) API. Table of Contents

Tandem Software Flow

Cyclone V SoC PCI-Express Root Port Example Design. Application Note

PUBLICATION. PCIExpress Hot-Plug Mechanism in Linux-based ATCA Control Systems

PEX8764, PCI Express Gen3 Switch, 64 Lanes, 16 Ports

HPE D2600/D2700 Disk Enclosure I/O Module Firmware 0149 Release Notes

VGA Assignment Using VFIO. Alex Williamson October 21 st, 2013

Building a Low-End to Mid-Range Router with PCI Express Switches

Computer Architecture Background

Release Notes CCURDSCC (WC-AD3224-DS)

HKG net_mdev: Fast-path userspace I/O. Ilias Apalodimas Mykyta Iziumtsev François-Frédéric Ozog

Red Hat Virtualization 4.1 Hardware Considerations for Implementing SR-IOV

T A B L E O F C O N T E N T S

Neousys Technology Inc. PCIe-PoE354at/PCIe-PoE352at. User s Manual. Rev. A1

Red Hat Enterprise Virtualization 3.6

Fibre Channel Adapter and Converged Network Adapter Inbox Driver Update for Linux Kernel 2.6.x and 3.x. Readme. QLogic Corporation All rights reserved

Release Notes CCURPMFC (WC-CP-FIO)

PowerEdge FX2 - Upgrading from 10GbE Pass-through Modules to FN410S I/O Modules

Critical Resource Analysis (CRA) White Paper

Data Communication and Synchronization

Unify Virtual and Physical Networking with Cisco Virtual Interface Card

I/O Systems. Jo, Heeseung

Dell PowerEdge R720xd with PERC H710P: A Balanced Configuration for Microsoft Exchange 2010 Solutions

LINUX DEVICE DRIVERS Weekend Workshop

Artisan Technology Group is your source for quality new and certified-used/pre-owned equipment

MSA1500csReleaseNotes8_ txt MSA1500cs ReleaseNotes. hp StorageWorks Modular Smart Array 1500 cs Release Notes. Third Edition (February 2005)

Linux DRM Developer s Guide

10 Having Hot Spare disks available in the system is strongly recommended. There are two types of Hot Spare disks:

3ware Release Notes Supporting 9690SA and 9650SE controllers

Lattice PCI Express Demo Installation User s Guide

Architecture Specification

Compression Device Drivers. Release

USB to Serial Adapter Driver Installation Manual

Consistent Network Device Naming in Linux

SDK. About the Cisco SDK. Installing the SDK. Procedure. This chapter contains the following sections:

Virtual Iron Software Release Notes

4 Port Quad Bus PCI Express (PCIe) SuperSpeed USB 3.0 Card Adapter with UASP - SATA/LP4 Power

Neousys Technology Inc. PCIe-PoE2+/PCIe-PoE4+ User s Manual. Rev. A1

Jeff Dodson / Avago Technologies

PCIEMODBOX232 RS232 to PCI Module Box Introduction

DKOM (Direct Kernel Object Manipulation)

Certified Wireless USB Wire Adapter Model

T A B L E O F C O N T E N T S

Z400 / AVID Qualified Operating System choices: Microsoft Windows 7 Professional 64-bit Edition with Service Pack 1

Manually Mount Usb Flash Drive Linux Command Line Redhat

AN 829: PCI Express* Avalon -MM DMA Reference Design

SANsurfer FC/CNA HBA Command Line Interface (CLI) Table of Contents

CSX600 Runtime Software. User Guide

Rawdev Drivers. Release rc4


Transcription:

PCIe Hot-Swap Device Driver Application Note AN-546 Introduction By Craig Hackney In typical PCIe based systems, PCIe buses are enumerated and resources allocated to each PCIe endpoint device during system initialization. Due to limitations in the enumeration and resource allocation algorithms, once initialized, the PCIe topology is fixed, meaning no new endpoint devices or switches may be connected to the system. Root Complex Fibre Channel Controller FC FC Dual GbE Controller GbE GbE SATA / SAS Controller Figure 1 Typical PCIe Topology The IDT PCIe Hot-Swap driver is a loadable Linux module that employs IDT proprietary enumeration, resource allocation, and device detection algorithms, allowing PCIe endpoint devices and switches to be connected to or disconnected from a system at runtime without compromising the operational state of the other PCIe devices in system. Using Figure 1 as reference, if the dual GigE controller is disconnected from the system and subsequently reconnected to a port on a different switch, the operational state of the Fibre Channel controller and the SATA/SAS controller will remain unchanged. This differs from the Windows Vista implementation of PCIe Hot-Plug which must disable, re-enumerate, and reallocate resources to all devices sharing the same root port before the newly connected device becomes operational. Devices may simply be connected to or disconnected from the system in an arbitrary fashion or in a more graceful fashion by writing to files located under the /sysfs directory. Writing 0 to the /sysfs/bus/pci/slots/0000:bb:dd.f/power file (where bb specifies the bus number, dd specifies the device number, and f specifies the function number of a downstream port) will disable the specified downstream port whilst writing a 1 to the same file will enable the downstream port. When a downstream port is disabled, all devices connected to that port are removed from the Linux kernel and the PCI drivers remove() function will be called to perform the required cleanup. By the same token, when a downstream port is enabled, any devices connected to it will be discovered, 2008 Integrated Device Technology, Inc. 1 of 8 June 16, 2008

added to the Linux kernel and the PCI drivers probe() function will be called to perform the device initialization. Downstream ports may also be enabled or disabled by third-party kernel mode drivers by utilizing the Hot-Swap drivers API described in the section titled Enabling and Disabling Downstream Ports. Figure 2 below depicts examples of the types of devices that may be connected to or disconnected from a system running the IDT PCIe Hot-Swap driver. Root Complex Fibre Channel Controller FC FC Dual GbE Controller GbE GbE SATA / SAS Controller Figure 2 Device Removal The key to achieving this type of Hot-Swap functionality is the ability to assign additional unused bus numbers and memory resources to each downstream port in the system. When a new device is connected to the system, these additional resources are utilized in order to bring the device to an operational state without having to compromise the operational state of the other devices sharing the same root port. System Interconnect Considerations The IDT System Interconnect Topology [1] shown in Figure 3 consists of a single based Root Complex Processor (RP) connected to one or more intelligent based Endpoint Processors (EP) via an IDT System Interconnect PCIe switch. An IDT Inter-Domain switch is utilized by each EP to connected them to the downstream ports of the System Interconnect PCIe switch. This topology in conjunction with the IDT System Interconnect Software [2] allows high speed data transfer between any two peers in the system. 2 of 8 June 16, 2008

Root Complex Processor Endpoint Processor 1 Endpoint Processor 2 Endpoint Processor n Figure 3 IDT System Interconnect Topology When a new EP is connected to or disconnected from a system utilizing this type of topology, the Hot- Swap driver treats the EP the same as any normal endpoint device. There is, however, a difference in the way in which an RP is treated when it is connected to or disconnected from the system. Root Complex Processor Endpoint Processor 1 Endpoint Processor 2 Endpoint Processor n Figure 4 System Interconnect Root Complex Processor Removal Typically, when the upstream port of a PCIe switch is disconnected as shown in Figure 4, the switch will issue a hot reset to all of its downstream ports. This functionality is undesirable in the System Interconnect topology since it would prevent the EPs from communicating with each other when the RP is disconnected from the system. The Hot-Swap driver overcomes this issue by detecting IDT PCIe System Interconnect 3 of 8 June 16, 2008

Switches and disabling their ability to generate a hot reset when their upstream ports are disconnected.this functionality may be disabled in the Hot-Swap driver by setting the linkdownhotreset module parameter to a non zero value. The Hot-Swap driver also sports a passive resource allocation algorithm. Used primarily with the IDT System Interconnect Topology, this algorithm allows an RP to be connected to an operational system with minimal system interruption. Typically, when an endpoint device is connected to the Root Complex, it is the Root Complex that assigns memory resources to the device. In the case of passive resource allocation, it is the Root Complex that is being connected to the system and the endpoint devices that inform the Root Complex which memory resources should be used. This functionality is enabled by default in the Hot-Swap driver, but it may be disabled by setting the passiveallocationdisable module parameter. Supported Architectures The IDT PCIe Hot-Swap driver module is supported on and has been tested with the following environment. Fedora Core 6 (kernel version 2.6.18) GCC 4.1.1 Intel Bensley & Stoakley based PC s AMD K8N based PC s Driver Operation It may not be desirable to have all PCIe root ports on a system hot-swapable. For this reason, when the driver module is loaded, the slots module parameter may be used to specify which PCIe root ports should be placed under the control of the Hot-Swap driver. Bus Enumeration The number of buses assigned to each root port may be specified by the minrootbuses module parameter (set to 32 by default) when the driver is loaded. Should a switch be connected to the system at runtime, the number of buses assigned to the parent port are shared evenly between the downstream ports of the newly connected switch. Device Detection One of the most important aspects of any Hot-Swap driver is to be able to successfully detect when a device has been connected to or disconnected from the system. Since there is no defined methodology to perform such a task, the IDT Hot-Swap driver employs a three tier approach in order to successfully detect PCIe devices. First, the link capabilities register on all downstream ports is checked to see if it supports Data Link Layer Link Active (DLLLA) status reporting. If DLLLA is supported, the DLLLA status is used to determine when a device is connected or disconnected. Second, some manufactures have a vendor-specific status register that may be used to determine if a device is connected. Although this results in software changes to the Hot-Swap driver, the driver already contains the hooks necessary to implement custom link status checking functions on a per vendor/device ID basis. Third, an attempt is made to perform configuration reads to obtain the device/vendor ID of the device connected to the downstream ports. If a device is connected, a valid device/vendor ID will be returned. If no device is connected, 0xffff will be returned for the vendor/device ID. 4 of 8 June 16, 2008

Resource Allocation As with the bus enumeration, a module parameter rootiomemsize is used to specify the amount of memory space that should be allocated to each root port under the control of the Hot-Swap driver (defaults to 0x2000000 bytes). Should a new switch be connected to the system at runtime, the memory resources allocated to the parent port will be shared evenly between the downstream ports of the newly connected switch. Device Driver Application Programming Interface The following sections describe the API exported by the Hot-swap driver for use by third-party software. Custom Link Status Checking The Hot-swap driver exports the following function that allows a third-party kernel mode driver to assign a custom link status checking function to the specified downstream port. void *registerlinkstatushandler(struct pci_dev *dev, int (*handler)(struct pci_dev *dev)) Register a custom link status checking function. The handler parameter should be a pointer to a function that accepts a single parameter that points to the PCI device structure for the downstream port to be checked. The return value from the link status checking function should be 1 if a device is detected and 0 if a device is not detected. dev Pointer to the downstream ports PCI device structure. handler Pointer to the new link status checking function. Returns: A pointer to the previous link status handler if successful, otherwise NULL. Pausing Link Status Checking The Hot-swap driver exports the following function that allows a third-party kernel mode driver to pause the automatic link status check. int pauseresumelinkcheck(int pause) Pause or Resume the Hot-swap driver automatic link status checking. pause 1 to pause link checking, 0 to resume. 0 Link checking was previously running. 1 Link checking was previously paused. Preventing Link Status Checking The Hot-swap driver exports the following functions that allow a third-party kernel mode driver to exclude or include ports from automatic link status checking at runtime. int pciehotswapexclude(struct pci_dev *dev) Exclude the specified downstream port from automatic link status checking. dev Pointer to the PCI device structure for the downstream port. 5 of 8 June 16, 2008

0 Success. -ENODEV Device not found. int pciehotswapinclude(struct pci_dev *dev) Include the specified downstream port in automatic link status checking. The downstream port should first have been excluded from automatic link status checking by a call to pciehotswapexclude(). dev Pointer to the PCI device structure of the downstream port. 0 Success -ENODEV Device not found. -EINVAL Invalid device structure pointer. Enabling and Disabling Downstream Ports The Hot-swap driver exports the following functions that allow a third-party kernel mode driver to enable or disable a downstream port at runtime. int pciehotswapdisable(struct pci_dev *dev) Disable the specified downstream port. All devices connected to the port will be removed, all resources released and the PCI remove() function called for any drivers associated with the devices being removed. dev Pointer to the PCI device structure of the downstream port. 0 Success. -ENODEV Device not found. -EINVAL Invalid PCI device structure. int pciehotswapenable(struct pci_dev *dev) Enable the specified downstream port. Any devices or switches connected to the port being enabled are configured, resources allocated and the PCI probe() function is called for any drivers associated with the devices being added. dev Pointer to the PCI device structure of the downstream port. 0 Success. -ENODEV Device not found. -EINVAL Invalid PCI device structure. Building the Hot-Swap Driver The IDT PCIe Hot-Swap driver module requires access to a number of symbols that are private to the Linux kernel. In order for the driver to work correctly, the Linux kernel must be patched and rebuilt to allow access to the required symbols. Before building the kernel sources, it will be necessary to obtain a copy of the kernel source RPM (kernel-2.6.18.src.rpm) and the unifdef RPM (unifdef-1.171-5.fc6.i386.rpm). The following procedure should be used to install, configure, patch, and build the kernel sources while logged in as root. 6 of 8 June 16, 2008

Installing the RPMs rpm -ivh kernel-2.6.18.src.rpm rpm -ivh unifdef-1.171-5.fc6.i386.rpm Configuring the Sources cd /usr/src/redhat/specs rpmbuild -bp --target=<arch> kernel-2.6.spec (Where <arch> is the target architecture i.e. i686) Create a Symbolic Link to the Source ln -s /usr/src/redhat/build/kernel-2.6.18/linux-2.6.18 /usr/ src/linux Patch the Kernel cd /usr/src/linux patch -p0 < IDT_hotswap_2.6.18.patch (The patch file is located in the hotswap source directory) Configure the Kernel make oldconfig Build the Kernel make Install the new Kernel Modules make modules_install Install the new Kernel make install Edit /boot/grub/grub.conf and make sure that the default boot kernel is set to the newly built kernel before rebooting the machine. After the machine has been rebooted with the newly created kernel, the Hot-Swap driver may be built. Login as root and change to the directory that contains the Hot-Swap driver source code. Enter the following command to build and install the Hot-Swap driver module. make install Loading the Hot-Swap Driver Once installed, the Hot-Swap driver may be loaded by using the modprobe utility as shown below. modprobe idt-hotswap [module parameters] In order to automatically load the Hot-Swap driver when the machine boots, add the above command to the file called /etc/rc.modules. If /etc/rc.modules does not exist, create it with executable permissions. The Hot-Swap driver may be unloaded by invoking the modprobe utility with the -r command line option as shown below. modprobe -r idt-hotswap Module Parameters The following table lists the Hot-Swap driver module parameters, their default values, and their usage. 7 of 8 June 16, 2008

Parameter Name Default Value Description slots NULL Used to specify which root ports should be under the control of the Hot-Swap driver. The format of this parameter is bb:dd.f where bb is the bus number, dd is the device number and f is the function number of the root port to be controlled by the Hot-Swap driver. Multiple root ports may be specified if separated by a comma. exclude NULL Used to specify the downstream ports, in bb:dd.f format, that should be excluded from automatic link status checking when a link status checking function external to the Hot-swap driver is employed. Multiple downstream ports may be specified if separated by a comma. minrootbuses 32 The number of bus numbers that should be assigned to each root port specified by the slots parameter. rootiomemsize 0x2000000 The amount of IO memory space that should be assigned to each root port specified by the slots parameter. linkdownhotreset 0 When set to 1, any IDT System Interconnect switch will generate a hot reset to its downstream ports when its upstream port is disconnected. passiveallocationdisable 0 Set to 1 to disable passive resource allocation when not using the Hot-Swap driver with the IDT System Interconnect topology. firstbus 0 Used to specify the first bus number that should be used when re-enumerating the PCIe buses. If set to zero, the driver will use the next available bus number. debug 0 Set to 1 to enable diagnostic messages. References Table 1 Hot-Swap Driver Module Parameters [1] Enabling Multi-peer Support with a Standard-Based PCI Express multi-port Switch White Paper, Kwok Kong, IDT. [2] Application Note 571, PCI Express System Interconnect Software Architecture for -based Systems, Kwok Kong & Alex Chang, IDT. 8 of 8 June 16, 2008