RapidIO Subsystem Guide
Author: Matt Porter
Introduction #
RapidIO is a high speed switched fabric interconnect with features aimed at the embedded market. RapidIO provides support for memory-mapped I/O as well as message-based transactions over the switched fabric network. RapidIO has a standardized discovery mechanism not unlike the PCI bus standard that allows simple detection of devices in a network.
This documentation is provided for developers intending to support RapidIO on new architectures, write new drivers, or to understand the subsystem internals.
Known Bugs and Limitations #
Bugs #
None. ;)
Limitations #
-
Access/management of RapidIO memory regions is not supported
-
Multiple host enumeration is not supported
RapidIO driver interface #
Drivers are provided a set of calls in order to interface with the subsystem to gather info on devices, request/map memory region resources, and manage mailboxes/doorbells.
Functions #
rio_local_read_config_32() #
int Read 32 bits from local configuration space
Parameters
struct rio_mport *port: Master portu32 offset: Offset into local configuration spaceu32 * data: Pointer to read data into
Description
Reads 32 bits of data from the specified offset within the local device's configuration space.
rio_local_write_config_32() #
int Write 32 bits to local configuration space
Parameters
struct rio_mport *port: Master portu32 offset: Offset into local configuration spaceu32 data: Data to be written
Description
Writes 32 bits of data to the specified offset within the local device's configuration space.
rio_local_read_config_16() #
int Read 16 bits from local configuration space
Parameters
struct rio_mport *port: Master portu32 offset: Offset into local configuration spaceu16 * data: Pointer to read data into
Description
Reads 16 bits of data from the specified offset within the local device's configuration space.
rio_local_write_config_16() #
int Write 16 bits to local configuration space
Parameters
struct rio_mport *port: Master portu32 offset: Offset into local configuration spaceu16 data: Data to be written
Description
Writes 16 bits of data to the specified offset within the local device's configuration space.
rio_local_read_config_8() #
int Read 8 bits from local configuration space
Parameters
struct rio_mport *port: Master portu32 offset: Offset into local configuration spaceu8 * data: Pointer to read data into
Description
Reads 8 bits of data from the specified offset within the local device's configuration space.
rio_local_write_config_8() #
int Write 8 bits to local configuration space
Parameters
struct rio_mport *port: Master portu32 offset: Offset into local configuration spaceu8 data: Data to be written
Description
Writes 8 bits of data to the specified offset within the local device's configuration space.
rio_read_config_32() #
int Read 32 bits from configuration space
Parameters
struct rio_dev *rdev: RIO deviceu32 offset: Offset into device configuration spaceu32 * data: Pointer to read data into
Description
Reads 32 bits of data from the specified offset within the RIO device's configuration space.
rio_write_config_32() #
int Write 32 bits to configuration space
Parameters
struct rio_dev *rdev: RIO deviceu32 offset: Offset into device configuration spaceu32 data: Data to be written
Description
Writes 32 bits of data to the specified offset within the RIO device's configuration space.
rio_read_config_16() #
int Read 16 bits from configuration space
Parameters
struct rio_dev *rdev: RIO deviceu32 offset: Offset into device configuration spaceu16 * data: Pointer to read data into
Description
Reads 16 bits of data from the specified offset within the RIO device's configuration space.
rio_write_config_16() #
int Write 16 bits to configuration space
Parameters
struct rio_dev *rdev: RIO deviceu32 offset: Offset into device configuration spaceu16 data: Data to be written
Description
Writes 16 bits of data to the specified offset within the RIO device's configuration space.
rio_read_config_8() #
int Read 8 bits from configuration space
Parameters
struct rio_dev *rdev: RIO deviceu32 offset: Offset into device configuration spaceu8 * data: Pointer to read data into
Description
Reads 8 bits of data from the specified offset within the RIO device's configuration space.
rio_write_config_8() #
int Write 8 bits to configuration space
Parameters
struct rio_dev *rdev: RIO deviceu32 offset: Offset into device configuration spaceu8 data: Data to be written
Description
Writes 8 bits of data to the specified offset within the RIO device's configuration space.
rio_send_doorbell() #
int Send a doorbell message to a device
Parameters
struct rio_dev *rdev: RIO deviceu16 data: Doorbell message data
Description
Send a doorbell message to a RIO device. The doorbell message has a 16-bit info field provided by the data argument.
rio_init_mbox_res() #
void Initialize a RIO mailbox resource
Parameters
struct resource *res: resource structint start: start of mailbox rangeint end: end of mailbox range
Description
This function is used to initialize the fields of a resource for use as a mailbox resource. It initializes a range of mailboxes using the start and end arguments.
rio_init_dbell_res() #
void Initialize a RIO doorbell resource
Parameters
struct resource *res: resource structu16 start: start of doorbell rangeu16 end: end of doorbell range
Description
This function is used to initialize the fields of a resource for use as a doorbell resource. It initializes a range of doorbell messages using the start and end arguments.
RIO_DEVICE() #
macro used to describe a specific RIO device
Parameters
dev: the 16 bit RIO device IDven: the 16 bit RIO vendor ID
Description
This macro is used to create a struct rio_device_id that matches a
specific device. The assembly vendor and assembly device fields
will be set to RIO_ANY_ID.
rio_add_outb_message() #
int Add RIO message to an outbound mailbox queue
Parameters
struct rio_mport *mport: RIO master port containing the outbound queuestruct rio_dev *rdev: RIO device the message is be sent toint mbox: The outbound mailbox queuevoid *buffer: Pointer to the message buffersize_t len: Length of the message buffer
Description
Adds a RIO message buffer to an outbound mailbox queue for transmission. Returns 0 on success.
rio_add_inb_buffer() #
int Add buffer to an inbound mailbox queue
Parameters
struct rio_mport *mport: Master port containing the inbound mailboxint mbox: The inbound mailbox numbervoid *buffer: Pointer to the message buffer
Description
Adds a buffer to an inbound mailbox queue for reception. Returns 0 on success.
rio_get_inb_message() #
void * Get A RIO message from an inbound mailbox queue
Parameters
struct rio_mport *mport: Master port containing the inbound mailboxint mbox: The inbound mailbox number
Description
Get a RIO message from an inbound mailbox queue. Returns 0 on success.
rio_name() #
const char * Get the unique RIO device identifier
Parameters
struct rio_dev *rdev: RIO device
Description
Get the unique RIO device identifier. Returns the device identifier string.
rio_get_drvdata() #
void * Get RIO driver specific data
Parameters
struct rio_dev *rdev: RIO device
Description
Get RIO driver specific data. Returns a pointer to the driver specific data.
rio_set_drvdata() #
void Set RIO driver specific data
Parameters
struct rio_dev *rdev: RIO devicevoid *data: Pointer to driver specific data
Description
Set RIO driver specific data. device struct driver data pointer is set to the data argument.
rio_dev_get() #
struct rio_dev * Increments the reference count of the RIO device structure
Parameters
struct rio_dev *rdev: RIO device being referenced
Description
Each live reference to a device should be refcounted.
Drivers for RIO devices should normally record such references in
their probe() methods, when they bind to a device, and release
them by calling rio_dev_put(), in their disconnect() methods.
rio_dev_put() #
void Release a use of the RIO device structure
Parameters
struct rio_dev *rdev: RIO device being disconnected
Description
Must be called when a user of a device is finished with it. When the last user of the device calls this function, the memory of the device is freed.
rio_register_driver() #
int register a new RIO driver
Parameters
struct rio_driver *rdrv: the RIO driver structure to register
Description
Adds a struct rio_driver to the list of registered drivers.
Returns a negative value on error, otherwise 0. If no error
occurred, the driver remains registered even if no device
was claimed during registration.
rio_unregister_driver() #
void unregister a RIO driver
Parameters
struct rio_driver *rdrv: the RIO driver structure to unregister
Description
Deletes the struct rio_driver from the list of registered RIO
drivers, gives it a chance to clean up by calling its remove()
function for each device it was responsible for, and marks those
devices as driverless.
rio_local_get_device_id() #
u16 Get the base/extended device id for a port
Parameters
struct rio_mport *port: RIO master port from which to get the deviceid
Description
Reads the base/extended device id from the local device implementing the master port. Returns the 8/16-bit device id.
rio_query_mport() #
int Query mport device attributes
Parameters
struct rio_mport *port: mport device to querystruct rio_mport_attr *mport_attr: mport attributes data structure
Description
Returns attributes of specified mport through the pointer to attributes data structure.
rio_alloc_net() #
struct rio_net * Allocate and initialize a new RIO network data structure
Parameters
struct rio_mport *mport: Master port associated with the RIO network
Description
Allocates a RIO network structure, initializes per-network
list heads, and adds the associated master port to the
network list of associated master ports. Returns a
RIO network pointer on success or NULL on failure.
rio_local_set_device_id() #
void Set the base/extended device id for a port
Parameters
struct rio_mport *port: RIO master portu16 did: Device ID value to be written
Description
Writes the base/extended device id from a device.
rio_add_device() #
int Adds a RIO device to the device model
Parameters
struct rio_dev *rdev: RIO device
Description
Adds the RIO device to the global device list and adds the RIO device to the RIO device list. Creates the generic sysfs nodes for an RIO device.
rio_request_inb_mbox() #
int request inbound mailbox service
Parameters
struct rio_mport *mport: RIO master port from which to allocate the mailbox resourcevoid *dev_id: Device specific pointer to pass on eventint mbox: Mailbox number to claimint entries: Number of entries in inbound mailbox queuevoid (*minb) (struct rio_mport * mport, void *dev_id, int mbox, int slot): Callback to execute when inbound message is received
Description
Requests ownership of an inbound mailbox resource and binds
a callback function to the resource. Returns 0 on success.
rio_release_inb_mbox() #
int release inbound mailbox message service
Parameters
struct rio_mport *mport: RIO master port from which to release the mailbox resourceint mbox: Mailbox number to release
Description
Releases ownership of an inbound mailbox resource. Returns 0 if the request has been satisfied.
rio_request_outb_mbox() #
int request outbound mailbox service
Parameters
struct rio_mport *mport: RIO master port from which to allocate the mailbox resourcevoid *dev_id: Device specific pointer to pass on eventint mbox: Mailbox number to claimint entries: Number of entries in outbound mailbox queuevoid (*moutb) (struct rio_mport * mport, void *dev_id, int mbox, int slot): Callback to execute when outbound message is sent
Description
Requests ownership of an outbound mailbox resource and binds a callback function to the resource. Returns 0 on success.
rio_release_outb_mbox() #
int release outbound mailbox message service
Parameters
struct rio_mport *mport: RIO master port from which to release the mailbox resourceint mbox: Mailbox number to release
Description
Releases ownership of an inbound mailbox resource. Returns 0 if the request has been satisfied.
rio_request_inb_dbell() #
int request inbound doorbell message service
Parameters
struct rio_mport *mport: RIO master port from which to allocate the doorbell resourcevoid *dev_id: Device specific pointer to pass on eventu16 start: Doorbell info range startu16 end: Doorbell info range endvoid (*dinb) (struct rio_mport * mport, void *dev_id, u16 src, u16 dst, u16 info): Callback to execute when doorbell is received
Description
Requests ownership of an inbound doorbell resource and binds a callback function to the resource. Returns 0 if the request has been satisfied.
rio_release_inb_dbell() #
int release inbound doorbell message service
Parameters
struct rio_mport *mport: RIO master port from which to release the doorbell resourceu16 start: Doorbell info range startu16 end: Doorbell info range end
Description
Releases ownership of an inbound doorbell resource and removes callback from the doorbell event list. Returns 0 if the request has been satisfied.
rio_request_outb_dbell() #
struct resource * request outbound doorbell message range
Parameters
struct rio_dev *rdev: RIO device from which to allocate the doorbell resourceu16 start: Doorbell message range startu16 end: Doorbell message range end
Description
Requests ownership of a doorbell message range. Returns a resource
if the request has been satisfied or NULL on failure.
rio_release_outb_dbell() #
int release outbound doorbell message range
Parameters
struct rio_dev *rdev: RIO device from which to release the doorbell resourcestruct resource *res: Doorbell resource to be freed
Description
Releases ownership of a doorbell message range. Returns 0 if the request has been satisfied.
rio_add_mport_pw_handler() #
int add port-write message handler into the list of mport specific pw handlers
Parameters
struct rio_mport *mport: RIO master port to bind the portwrite callbackvoid *context: Handler specific context to pass on eventint (*pwcback)(struct rio_mport *mport, void *context, union rio_pw_msg *msg, int step): Callback to execute when portwrite is received
Description
Returns 0 if the request has been satisfied.
rio_del_mport_pw_handler() #
int remove port-write message handler from the list of mport specific pw handlers
Parameters
struct rio_mport *mport: RIO master port to bind the portwrite callbackvoid *context: Registered handler specific context to pass on eventint (*pwcback)(struct rio_mport *mport, void *context, union rio_pw_msg *msg, int step): Registered callback function
Description
Returns 0 if the request has been satisfied.
rio_request_inb_pwrite() #
int request inbound port-write message service for specific RapidIO device
Parameters
struct rio_dev *rdev: RIO device to which register inbound port-write callback routineint (*pwcback)(struct rio_dev *rdev, union rio_pw_msg *msg, int step): Callback routine to execute when port-write is received
Description
Binds a port-write callback function to the RapidIO device. Returns 0 if the request has been satisfied.
rio_release_inb_pwrite() #
int release inbound port-write message service associated with specific RapidIO device
Parameters
struct rio_dev *rdev: RIO device which registered for inbound port-write callback
Description
Removes callback from the rio_dev structure. Returns 0 if the request has been satisfied.
rio_pw_enable() #
void Enables/disables port-write handling by a master port
Parameters
struct rio_mport *mport: Master port associated with port-write handlingint enable: 1=enable, 0=disable
rio_map_inb_region() #
int - Map inbound memory region.
Parameters
struct rio_mport *mport: Master port.dma_addr_t local: physical address of memory region to be mappedu64 rbase: RIO base address assigned to this windowu32 size: Size of the memory regionu32 rflags: Flags for mapping.
Return
0 -- Success.
Description
This function will create the mapping from RIO space to local memory.
rio_unmap_inb_region() #
void - Unmap the inbound memory region
Parameters
struct rio_mport *mport: Master portdma_addr_t lstart: physical address of memory region to be unmapped
rio_map_outb_region() #
int - Map outbound memory region.
Parameters
struct rio_mport *mport: Master port.u16 destid: destination id window points tou64 rbase: RIO base address window translates tou32 size: Size of the memory regionu32 rflags: Flags for mapping.dma_addr_t *local: physical address of memory region mapped
Return
0 -- Success.
Description
This function will create the mapping from RIO space to local memory.
rio_unmap_outb_region() #
void - Unmap the inbound memory region
Parameters
struct rio_mport *mport: Master portu16 destid: destination id mapping points tou64 rstart: RIO base address window translates to
rio_mport_get_physefb() #
u32 Helper function that returns register offset for Physical Layer Extended Features Block.
Parameters
struct rio_mport *port: Master port to issue transactionint local: Indicate a local master port or remote device accessu16 destid: Destination ID of the deviceu8 hopcount: Number of switch hops to the deviceu32 *rmap: pointer to location to store register map type info
rio_get_comptag() #
struct rio_dev * Begin or continue searching for a RIO device by component tag
Parameters
u32 comp_tag: RIO component tag to matchstruct rio_dev *from: Previous RIO device found in search, orNULLfor new search
Description
Iterates through the list of known RIO devices. If a RIO device is
found with a matching comp_tag, a pointer to its device
structure is returned. Otherwise, NULL is returned. A new search
is initiated by passing NULL to the from argument. Otherwise, if
from is not NULL, searches continue from next device on the global
list.
rio_set_port_lockout() #
int Sets/clears LOCKOUT bit (RIO EM 1.3) for a switch port.
Parameters
struct rio_dev *rdev: Pointer to RIO device control structureu32 pnum: Switch port number to set LOCKOUT bitint lock: Operation : set (=1) or clear (=0)
rio_enable_rx_tx_port() #
int enable input receiver and output transmitter of given port
Parameters
struct rio_mport *port: Master port associated with the RIO networkint local: local=1 select local port otherwise a far device is reachedu16 destid: Destination ID of the device to check host bitu8 hopcount: Number of hops to reach the targetu8 port_num: Port (-number on switch) to enable on a far end device
Description
Returns 0 or 1 from on General Control Command and Status Register (EXT_PTR+0x3C)
rio_mport_chk_dev_access() #
int Validate access to the specified device.
Parameters
struct rio_mport *mport: Master port to send transactionsu16 destid: Device destination ID in networku8 hopcount: Number of hops into the network
rio_inb_pwrite_handler() #
int inbound port-write message handler
Parameters
struct rio_mport *mport: mport device associated with port-writeunion rio_pw_msg *pw_msg: pointer to inbound port-write message
Description
Processes an inbound port-write message. Returns 0 if the request has been satisfied.
rio_mport_get_efb() #
u32 get pointer to next extended features block
Parameters
struct rio_mport *port: Master port to issue transactionint local: Indicate a local master port or remote device accessu16 destid: Destination ID of the deviceu8 hopcount: Number of switch hops to the deviceu32 from: Offset of current Extended Feature block header (if 0 starts from ExtFeaturePtr)
rio_mport_get_feature() #
u32 query for devices' extended features
Parameters
struct rio_mport * port: Master port to issue transactionint local: Indicate a local master port or remote device accessu16 destid: Destination ID of the deviceu8 hopcount: Number of switch hops to the deviceint ftr: Extended feature code
Description
Tell if a device supports a given RapidIO capability. Returns the offset of the requested extended feature block within the device's RIO configuration space or 0 in case the device does not support it.
rio_lock_device() #
int Acquires host device lock for specified device
Parameters
struct rio_mport *port: Master port to send transactionu16 destid: Destination ID for device/switchu8 hopcount: Hopcount to reach switchint wait_ms: Max wait time in msec (0 = no timeout)
Description
Attepts to acquire host device lock for specified device Returns 0 if device lock acquired or EINVAL if timeout expires.
rio_unlock_device() #
int Releases host device lock for specified device
Parameters
struct rio_mport *port: Master port to send transactionu16 destid: Destination ID for device/switchu8 hopcount: Hopcount to reach switch
Description
Returns 0 if device lock released or EINVAL if fails.
rio_route_add_entry() #
int Add a route entry to a switch routing table
Parameters
struct rio_dev *rdev: RIO deviceu16 table: Routing table IDu16 route_destid: Destination ID to be routedu8 route_port: Port number to be routedint lock: apply a hardware lock on switch device flag (1=lock, 0=no_lock)
Description
If available calls the switch specific add_entry() method to add a route
entry into a switch routing table. Otherwise uses standard RT update method
as defined by RapidIO specification. A specific routing table can be selected
using the table argument if a switch has per port routing tables or
the standard (or global) table may be used by passing
RIO_GLOBAL_TABLE in table.
Returns 0 on success or -EINVAL on failure.
rio_route_get_entry() #
int Read an entry from a switch routing table
Parameters
struct rio_dev *rdev: RIO deviceu16 table: Routing table IDu16 route_destid: Destination ID to be routedu8 *route_port: Pointer to read port number intoint lock: apply a hardware lock on switch device flag (1=lock, 0=no_lock)
Description
If available calls the switch specific get_entry() method to fetch a route
entry from a switch routing table. Otherwise uses standard RT read method
as defined by RapidIO specification. A specific routing table can be selected
using the table argument if a switch has per port routing tables or
the standard (or global) table may be used by passing
RIO_GLOBAL_TABLE in table.
Returns 0 on success or -EINVAL on failure.
rio_route_clr_table() #
int Clear a switch routing table
Parameters
struct rio_dev *rdev: RIO deviceu16 table: Routing table IDint lock: apply a hardware lock on switch device flag (1=lock, 0=no_lock)
Description
If available calls the switch specific clr_table() method to clear a switch
routing table. Otherwise uses standard RT write method as defined by RapidIO
specification. A specific routing table can be selected using the table
argument if a switch has per port routing tables or the standard (or global)
table may be used by passing RIO_GLOBAL_TABLE in table.
Returns 0 on success or -EINVAL on failure.
rio_request_mport_dma() #
struct dma_chan * request RapidIO capable DMA channel associated with specified local RapidIO mport device.
Parameters
struct rio_mport *mport: RIO mport to perform DMA data transfers
Description
Returns pointer to allocated DMA channel or NULL if failed.
rio_release_dma() #
void release specified DMA channel
Parameters
struct dma_chan *dchan: DMA channel to release
rio_dma_prep_xfer() #
struct dma_async_tx_descriptor * RapidIO specific wrapper for device_prep_slave_sg callback defined by DMAENGINE.
Parameters
struct dma_chan *dchan: DMA channel to configureu16 destid: target RapidIO device destination IDstruct rio_dma_data *data: RIO specific data descriptorenum dma_transfer_direction direction: DMA data transfer direction (TO or FROM the device)unsigned long flags: dmaengine defined flags
Description
Initializes RapidIO capable DMA channel for the specified data transfer. Uses DMA channel private extension to pass information related to remote target RIO device.
Return
pointer to DMA transaction descriptor if successful, error-valued pointer or NULL if failed.
rio_register_scan() #
int enumeration/discovery method registration interface
Parameters
int mport_id: mport device ID for which fabric scan routine has to be set (RIO_MPORT_ANY = set for all available mports)struct rio_scan *scan_ops: enumeration/discovery operations structure
Description
Registers enumeration/discovery operations with RapidIO subsystem and attaches it to the specified mport device (or all available mports if RIO_MPORT_ANY is specified).
Returns error if the mport already has an enumerator attached to it. In case of RIO_MPORT_ANY skips mports with valid scan routines (no error).
Internals #
This chapter contains the autogenerated documentation of the RapidIO subsystem.
Structures #
struct rio_switch #
RIO switch info
Definition
;
Members
node: Node in global list of switchesroute_table: Copy of switch routing tableport_ok: Status of each port (one bit per port) - OK=1 or UNINIT=0ops: pointer to switch-specific operationslock: lock to serialize operations updatesnextdev: Array of per-port pointers to the next attached device
struct rio_switch_ops #
Per-switch operations
Definition
;
Members
owner: The module owner of this structureadd_entry: Callback for switch-specific route add functionget_entry: Callback for switch-specific route get functionclr_table: Callback for switch-specific clear route table functionset_domain: Callback for switch-specific domain setting functionget_domain: Callback for switch-specific domain get functionem_init: Callback for switch-specific error management init functionem_handle: Callback for switch-specific error management handler function
Description
Defines the operations that are necessary to initialize/control a particular RIO switch device.
struct rio_dev #
RIO device info
Definition
;
Members
global_list: Node in list of all RIO devicesnet_list: Node in list of RIO devices in a networknet: Network this device is a part ofdo_enum: Enumeration flagdid: Device IDvid: Vendor IDdevice_rev: Device revisionasm_did: Assembly device IDasm_vid: Assembly vendor IDasm_rev: Assembly revisionefptr: Extended feature pointerpef: Processing element featuresswpinfo: Switch port infosrc_ops: Source operation capabilitiesdst_ops: Destination operation capabilitiescomp_tag: RIO component tagphys_efptr: RIO device extended features pointerphys_rmap: LP-Serial Register Map Type (1 or 2)em_efptr: RIO Error Management features pointerdma_mask: Mask of bits of RIO address this device implementsdriver: Driver claiming this devicedev: Device model deviceriores: RIO resources this device ownspwcback: port-write callback function for this devicedestid: Network destination ID (or associated destid for switch)hopcount: Hopcount to this deviceprev: Previous RIO device connected to the current onestate: device staterswitch: struct rio_switch (if valid for this device)
struct rio_msg #
RIO message event
Definition
;
Members
res: Mailbox resourcemcback: Message event callback
struct rio_dbell #
RIO doorbell event
Definition
;
Members
node: Node in list of doorbell eventsres: Doorbell resourcedinb: Doorbell event callbackdev_id: Device specific pointer to pass on event
struct rio_mport #
RIO master port info
Definition
;
Members
dbells: List of doorbell eventspwrites: List of portwrite eventsnode: Node in global list of master portsnnode: Node in network list of master portsnet: RIO net this mport is attached tolock: lock to synchronize lists manipulationsiores: I/O mem resource that this master port interface ownsriores: RIO resources that this master port interfaces ownsinb_msg: RIO inbound message event descriptorsoutb_msg: RIO outbound message event descriptorshost_deviceid: Host device ID associated with this master portops: configuration space functionsid: Port ID, unique among all portsindex: Port index, unique among all port interfaces of the same typesys_size: RapidIO common transport system sizephys_efptr: RIO port extended features pointerphys_rmap: LP-Serial EFB Register Mapping type (1 or 2).name: Port name stringdev: device structure associated with an mportpriv: Master port private datadma: DMA device associated with mportnscan: RapidIO network enumeration/discovery operationsstate: mport device statepwe_refcnt: port-write enable ref counter to track enable/disable requests
struct rio_net #
RIO network info
Definition
;
Members
node: Node in global list of RIO networksdevices: List of devices in this networkswitches: List of switches in this networkmports: List of master ports accessing this networkhport: Default port for accessing this networkid: RIO network IDdev: Device objectenum_data: private data specific to a network enumeratorrelease: enumerator-specific release callback
struct rio_mport_attr #
RIO mport device attributes
Definition
;
Members
flags: mport device capability flagslink_speed: SRIO link speed value (as defined by RapidIO specification)link_width: SRIO link width value (as defined by RapidIO specification)dma_max_sge: number of SG list entries that can be handled by DMA channel(s)dma_max_size: max number of bytes in single DMA transfer (SG entry)dma_align: alignment shift for DMA operations (as for other DMA operations)
struct rio_ops #
Low-level RIO configuration space operations
Definition
;
Members
lcread: Callback to perform local (master port) read of config space.lcwrite: Callback to perform local (master port) write of config space.cread: Callback to perform network read of config space.cwrite: Callback to perform network write of config space.dsend: Callback to send a doorbell message.pwenable: Callback to enable/disable port-write message handling.open_outb_mbox: Callback to initialize outbound mailbox.close_outb_mbox: Callback to shut down outbound mailbox.open_inb_mbox: Callback to initialize inbound mailbox.close_inb_mbox: Callback to shut down inbound mailbox.add_outb_message: Callback to add a message to an outbound mailbox queue.add_inb_buffer: Callback to add a buffer to an inbound mailbox queue.get_inb_message: Callback to get a message from an inbound mailbox queue.map_inb: Callback to map RapidIO address region into local memory space.unmap_inb: Callback to unmap RapidIO address region mapped withmap_inb().query_mport: Callback to query mport device attributes.map_outb: Callback to map outbound address region into local memory space.unmap_outb: Callback to unmap outbound RapidIO address region.
struct rio_driver #
RIO driver info
Definition
;
Members
node: Node in list of driversname: RIO driver nameid_table: RIO device ids to be associated with this driverprobe: RIO device insertedremove: RIO device removedshutdown: shutdown notification callbacksuspend: RIO device suspendedresume: RIO device awakenedenable_wake: RIO device enable wake eventdriver: LDM driver struct
Description
Provides info on a RIO device driver for insertion/removal and power management purposes.
struct rio_scan #
RIO enumeration and discovery operations
Definition
;
Members
owner: The module owner of this structureenumerate: Callback to perform RapidIO fabric enumeration.discover: Callback to perform RapidIO fabric discovery.
struct rio_scan_node #
list node to register RapidIO enumeration and discovery methods with RapidIO core.
Definition
;
Members
mport_id: ID of an mport (net) serviced by this enumeratornode: node in global list of registered enumeratorsops: RIO enumeration and discovery operations
Enumeration and Discovery #
rio_destid_alloc() #
u16 Allocate next available destID for given network
Parameters
struct rio_net *net: RIO network
Description
Returns next available device destination ID for the specified RIO network. Marks allocated ID as one in use. Returns RIO_INVALID_DESTID if new destID is not available.
rio_destid_reserve() #
int Reserve the specified destID
Parameters
struct rio_net *net: RIO networku16 destid: destID to reserve
Description
Tries to reserve the specified destID. Returns 0 if successful.
rio_destid_free() #
void free a previously allocated destID
Parameters
struct rio_net *net: RIO networku16 destid: destID to free
Description
Makes the specified destID available for use.
rio_destid_first() #
u16 return first destID in use
Parameters
struct rio_net *net: RIO network
rio_destid_next() #
u16 return next destID in use
Parameters
struct rio_net *net: RIO networku16 from: destination ID from which search shall continue
rio_get_device_id() #
u16 Get the base/extended device id for a device
Parameters
struct rio_mport *port: RIO master portu16 destid: Destination ID of deviceu8 hopcount: Hopcount to device
Description
Reads the base/extended device id from a device. Returns the 8/16-bit device ID.
rio_set_device_id() #
void Set the base/extended device id for a device
Parameters
struct rio_mport *port: RIO master portu16 destid: Destination ID of deviceu8 hopcount: Hopcount to deviceu16 did: Device ID value to be written
Description
Writes the base/extended device id from a device.
rio_clear_locks() #
int Release all host locks and signal enumeration complete
Parameters
struct rio_net *net: RIO network to run on
Description
Marks the component tag CSR on each device with the enumeration
complete flag. When complete, it then release the host locks on
each device. Returns 0 on success or -EINVAL on failure.
rio_enum_host() #
int Set host lock and initialize host destination ID
Parameters
struct rio_mport *port: Master port to issue transaction
Description
Sets the local host master port lock and destination ID register
with the host device ID value. The host device ID value is provided
by the platform. Returns 0 on success or -1 on failure.
rio_device_has_destid() #
int Test if a device contains a destination ID register
Parameters
struct rio_mport *port: Master port to issue transactionint src_ops: RIO device source operationsint dst_ops: RIO device destination operations
Description
Checks the provided src_ops and dst_ops for the necessary transaction capabilities that indicate whether or not a device will implement a destination ID register. Returns 1 if true or 0 if false.
rio_release_dev() #
void Frees a RIO device struct
Parameters
struct device *dev: LDM device associated with a RIO device struct
Description
Gets the RIO device struct associated a RIO device struct. The RIO device struct is freed.
rio_is_switch() #
int Tests if a RIO device has switch capabilities
Parameters
struct rio_dev *rdev: RIO device
Description
Gets the RIO device Processing Element Features register contents and tests for switch capabilities. Returns 1 if the device is a switch or 0 if it is not a switch. The RIO device struct is freed.
rio_setup_device() #
struct rio_dev * Allocates and sets up a RIO device
Parameters
struct rio_net *net: RIO networkstruct rio_mport *port: Master port to send transactionsu16 destid: Current destination IDu8 hopcount: Current hopcountint do_enum: Enumeration/Discovery mode flag
Description
Allocates a RIO device and configures fields based on configuration space contents. If device has a destination ID register, a destination ID is either assigned in enumeration mode or read from configuration space in discovery mode. If the device has switch capabilities, then a switch is allocated and configured appropriately. Returns a pointer to a RIO device on success or NULL on failure.
rio_sport_is_active() #
int Tests if a switch port has an active connection.
Parameters
struct rio_dev *rdev: RapidIO device objectint sp: Switch port number
Description
Reads the port error status CSR for a particular switch port to
determine if the port has an active link. Returns
RIO_PORT_N_ERR_STS_PORT_OK if the port is active or 0 if it is
inactive.
rio_get_host_deviceid_lock() #
u16 Reads the Host Device ID Lock CSR on a device
Parameters
struct rio_mport *port: Master port to send transactionu8 hopcount: Number of hops to the device
Description
Used during enumeration to read the Host Device ID Lock CSR on a RIO device. Returns the value of the lock register.
rio_enum_peer() #
int Recursively enumerate a RIO network through a master port
Parameters
struct rio_net *net: RIO network being enumeratedstruct rio_mport *port: Master port to send transactionsu8 hopcount: Number of hops into the networkstruct rio_dev *prev: Previous RIO device connected to the enumerated oneint prev_port: Port on previous RIO device
Description
Recursively enumerates a RIO network. Transactions are sent via the master port passed in port.
rio_enum_complete() #
int Tests if enumeration of a network is complete
Parameters
struct rio_mport *port: Master port to send transaction
Description
Tests the PGCCSR discovered bit for non-zero value (enumeration
complete flag). Return 1 if enumeration is complete or 0 if
enumeration is incomplete.
rio_disc_peer() #
int Recursively discovers a RIO network through a master port
Parameters
struct rio_net *net: RIO network being discoveredstruct rio_mport *port: Master port to send transactionsu16 destid: Current destination ID in networku8 hopcount: Number of hops into the networkstruct rio_dev *prev: previous rio_devint prev_port: previous port number
Description
Recursively discovers a RIO network. Transactions are sent via the master port passed in port.
rio_mport_is_active() #
int Tests if master port link is active
Parameters
struct rio_mport *port: Master port to test
Description
Reads the port error status CSR for the master port to
determine if the port has an active link. Returns
RIO_PORT_N_ERR_STS_PORT_OK if the master port is active
or 0 if it is inactive.
rio_update_route_tables() #
void Updates route tables in switches
Parameters
struct rio_net *net: RIO network to run update on
Description
For each enumerated device, ensure that each switch in a system has correct routing entries. Add routes for devices that where unknown during the first enumeration pass through the switch.
rio_init_em() #
void Initializes RIO Error Management (for switches)
Parameters
struct rio_dev *rdev: RIO device
Description
For each enumerated switch, call device-specific error management initialization routine (if supplied by the switch driver).
rio_enum_mport() #
int Start enumeration through a master port
Parameters
struct rio_mport *mport: Master port to send transactionsu32 flags: Enumeration control flags
Description
Starts the enumeration process. If somebody has enumerated our
master port device, then give up. If not and we have an active
link, then start recursive peer enumeration. Returns 0 if
enumeration succeeds or -EBUSY if enumeration fails.
rio_build_route_tables() #
void Generate route tables from switch route entries
Parameters
struct rio_net *net: RIO network to run route tables scan on
Description
For each switch device, generate a route table by copying existing route entries from the switch.
rio_disc_mport() #
int Start discovery through a master port
Parameters
struct rio_mport *mport: Master port to send transactionsu32 flags: discovery control flags
Description
Starts the discovery process. If we have an active link,
then wait for the signal that enumeration is complete (if wait
is allowed).
When enumeration completion is signaled, start recursive
peer discovery. Returns 0 if discovery succeeds or -EBUSY
on failure.
rio_basic_attach() #
int Parameters
void: no arguments
Description
When this enumeration/discovery method is loaded as a module this function registers its specific enumeration and discover routines for all available RapidIO mport devices. The "scan" command line parameter controls ability of the module to start RapidIO enumeration/discovery automatically.
Returns 0 for success or -EIO if unable to register itself.
This enumeration/discovery method cannot be unloaded and therefore does not provide a matching cleanup_module routine.
Driver functionality #
rio_setup_inb_dbell() #
int bind inbound doorbell callback
Parameters
struct rio_mport *mport: RIO master port to bind the doorbell callbackvoid *dev_id: Device specific pointer to pass on eventstruct resource *res: Doorbell message resourcevoid (*dinb) (struct rio_mport * mport, void *dev_id, u16 src, u16 dst, u16 info): Callback to execute when doorbell is received
Description
Adds a doorbell resource/callback pair into a port's doorbell event list. Returns 0 if the request has been satisfied.
rio_chk_dev_route() #
int Validate route to the specified device.
Parameters
struct rio_dev *rdev: RIO device failed to respondstruct rio_dev **nrdev: Last active device on the route to rdevint *npnum: nrdev's port number on the route to rdev
Description
Follows a route to the specified RIO device to determine the last available device (and corresponding RIO port) on the route.
rio_chk_dev_access() #
int Validate access to the specified device.
Parameters
struct rio_dev *rdev: Pointer to RIO device control structure
rio_get_input_status() #
int Sends a Link-Request/Input-Status control symbol and returns link-response (if requested).
Parameters
struct rio_dev *rdev: RIO devive to issue Input-status commandint pnum: Device port number to issue the commandu32 *lnkresp: Response from a link partner
rio_clr_err_stopped() #
int Clears port Error-stopped states.
Parameters
struct rio_dev *rdev: Pointer to RIO device control structureu32 pnum: Switch port number to clear errorsu32 err_status: port error status (if 0 reads register from device)
Description
TODO: Currently this routine is not compatible with recovery process specified for idt_gen3 RapidIO switch devices. It has to be reviewed to implement universal recovery process that is compatible full range off available devices. IDT gen3 switch driver now implements HW-specific error handler that issues soft port reset to the port to reset ERR_STOP bits and ackIDs.
rio_std_route_add_entry() #
int Add switch route table entry using standard registers defined in RIO specification rev.1.3
Parameters
struct rio_mport *mport: Master port to issue transactionu16 destid: Destination ID of the deviceu8 hopcount: Number of switch hops to the deviceu16 table: routing table ID (global or port-specific)u16 route_destid: destID entry in the RTu8 route_port: destination port for specified destID
rio_std_route_get_entry() #
int Read switch route table entry (port number) associated with specified destID using standard registers defined in RIO specification rev.1.3
Parameters
struct rio_mport *mport: Master port to issue transactionu16 destid: Destination ID of the deviceu8 hopcount: Number of switch hops to the deviceu16 table: routing table ID (global or port-specific)u16 route_destid: destID entry in the RTu8 *route_port: returned destination port for specified destID
rio_std_route_clr_table() #
int Clear swotch route table using standard registers defined in RIO specification rev.1.3.
Parameters
struct rio_mport *mport: Master port to issue transactionu16 destid: Destination ID of the deviceu8 hopcount: Number of switch hops to the deviceu16 table: routing table ID (global or port-specific)
rio_mport_scan() #
int execute enumeration/discovery on the specified mport
Parameters
int mport_id: number (ID) of mport device
RIO_LOP_READ() #
Generate rio_local_read_config_* functions
Parameters
size: Size of configuration space read (8, 16, 32 bits)type: C type of value argumentlen: Length of configuration space read (1, 2, 4 bytes)
Description
Generates rio_local_read_config_* functions used to access configuration space registers on the local device.
RIO_LOP_WRITE() #
Generate rio_local_write_config_* functions
Parameters
size: Size of configuration space write (8, 16, 32 bits)type: C type of value argumentlen: Length of configuration space write (1, 2, 4 bytes)
Description
Generates rio_local_write_config_* functions used to access configuration space registers on the local device.
RIO_OP_READ() #
Generate rio_mport_read_config_* functions
Parameters
size: Size of configuration space read (8, 16, 32 bits)type: C type of value argumentlen: Length of configuration space read (1, 2, 4 bytes)
Description
Generates rio_mport_read_config_* functions used to access configuration space registers on the local device.
RIO_OP_WRITE() #
Generate rio_mport_write_config_* functions
Parameters
size: Size of configuration space write (8, 16, 32 bits)type: C type of value argumentlen: Length of configuration space write (1, 2, 4 bytes)
Description
Generates rio_mport_write_config_* functions used to access configuration space registers on the local device.
Device model support #
rio_match_device() #
const struct rio_device_id * Tell if a RIO device has a matching RIO device id structure
Parameters
const struct rio_device_id *id: the RIO device id structure to match againstconst struct rio_dev *rdev: the RIO device structure to match against
Description
Used from driver probe and bus matching to check whether a RIO device
matches a device id structure provided by a RIO driver. Returns the
matching struct rio_device_id or NULL if there is no match.
rio_device_probe() #
int Tell if a RIO device structure has a matching RIO device id structure
Parameters
struct device *dev: the RIO device structure to match against
Description
return 0 and set rio_dev->driver when drv claims rio_dev, else error
rio_device_remove() #
void Remove a RIO device from the system
Parameters
struct device *dev: the RIO device structure to match against
Description
Remove a RIO device from the system. If it has an associated
driver, then run the driver remove() method. Then update
the reference count.
rio_match_bus() #
int Tell if a RIO device structure has a matching RIO driver device id structure
Parameters
struct device *dev: the standard device structure to match againstconst struct device_driver *drv: the standard driver structure containing the ids to match against
Description
Used by a driver to check whether a RIO device present in the
system is in its list of supported devices. Returns 1 if
there is a matching struct rio_device_id or 0 if there is
no match.
rio_bus_init() #
int Register the RapidIO bus with the device model
Parameters
void: no arguments
Description
Registers the RIO mport device class and RIO bus type with the Linux device model.
PPC32 support #
fsl_local_config_read() #
int Generate a MPC85xx local config space read
Parameters
struct rio_mport *mport: RapidIO master port infoint index: ID of RapdiIO interfaceu32 offset: Offset into configuration spaceint len: Length (in bytes) of the maintenance transactionu32 *data: Value to be read into
Description
Generates a MPC85xx local configuration space read. Returns 0 on
success or -EINVAL on failure.
fsl_local_config_write() #
int Generate a MPC85xx local config space write
Parameters
struct rio_mport *mport: RapidIO master port infoint index: ID of RapdiIO interfaceu32 offset: Offset into configuration spaceint len: Length (in bytes) of the maintenance transactionu32 data: Value to be written
Description
Generates a MPC85xx local configuration space write. Returns 0 on
success or -EINVAL on failure.
fsl_rio_config_read() #
int Generate a MPC85xx read maintenance transaction
Parameters
struct rio_mport *mport: RapidIO master port infoint index: ID of RapdiIO interfaceu16 destid: Destination ID of transactionu8 hopcount: Number of hops to target deviceu32 offset: Offset into configuration spaceint len: Length (in bytes) of the maintenance transactionu32 *val: Location to be read into
Description
Generates a MPC85xx read maintenance transaction. Returns 0 on
success or -EINVAL on failure.
fsl_rio_config_write() #
int Generate a MPC85xx write maintenance transaction
Parameters
struct rio_mport *mport: RapidIO master port infoint index: ID of RapdiIO interfaceu16 destid: Destination ID of transactionu8 hopcount: Number of hops to target deviceu32 offset: Offset into configuration spaceint len: Length (in bytes) of the maintenance transactionu32 val: Value to be written
Description
Generates an MPC85xx write maintenance transaction. Returns 0 on
success or -EINVAL on failure.
fsl_rio_setup() #
int Setup Freescale PowerPC RapidIO interface
Parameters
struct platform_device *dev: platform_device pointer
Description
Initializes MPC85xx RapidIO hardware interface, configures master port with system-specific info, and registers the master port with the RapidIO subsystem.
Credits #
The following people have contributed to the RapidIO subsystem directly or indirectly:
-
Matt Portermporter@kernel.crashing.org
-
Randy Vinsonrvinson@mvista.com
-
Dan Malekdan@embeddedalley.com
The following people have contributed to this document:
- Matt Portermporter@kernel.crashing.org