3.1. rdma.devices
module¶
The Linux RDMA discovery module determines the devices in the system by probing in sysfs. The objects returned all defer their sysfs operations until necessary and then cache the results. This means that none of the objects and properties track runtime changes to the sysfs files. Depending on the application this is either OK or disastrous.
When using verbs, the integerated
rdma.ibverbs.Context.handle_async_event()
method will update the
rdma.devices.EndPort
in response to async events from the kernel
indicating that the cached data is out of date.
The rdma.devices.RDMADevice
and rdma.devices.EndPort
contain
properties that return the various IBA defined quantities.
Note
Currently this really only correctly supports IB devices. Other technologies will probably need subclasses that include appropriate properties. eg iWarp devices do not have PKeys.
This module provides a list of IB devices pulled from from sysfs
-
class
rdma.devices.
DemandList
(path, conv, iconv=<type 'int'>)¶ Bases:
_abcoll.Iterable
Present an ordered list interface with a non-integer index for a set of values that are demand created. The list indexes must be known in advance.
The indexes are computed as:
sorted(iconv(I) for I in os.listdir(path))
conv is called to convert the contents of each file in path to the python representation.
-
clear
()¶ Drop the cache
-
first
()¶ Return the first element of the list
-
index
(value)¶ Return the index idx such that
obj[idx] == value
.
-
iterkeys
()¶
-
itervalues
()¶
-
-
class
rdma.devices.
DemandList2
(path, conv, iconv=<type 'int'>)¶ Bases:
rdma.devices.DemandList
Like
DemandList
but conv is a function to call with the idx, not file content. This is useful for cases where the path argument to__init__()
points to a list of directories.The indexes are computed as:
sorted(iconv(I) for I in os.listdir(path))
conv is called to convert the contents of each file in path to the python representation.
-
class
rdma.devices.
EndPort
(parent, port_id)¶ Bases:
rdma.devices.SysFSCache
A RDMA end port. An end port can issue RDMA operations, has a port GID, LID, etc. For an IB switch this will be port 0, for a *CA it will be port 1 or higher.
parent is the owning
RDMADevice
and port_id is the port ID number, 0 for switches and > 1 for *CAs-
cap_mask
¶ The value of
rdma.IBA.SMPPortInfo.capabilityMask
for this end port.
-
default_gid
¶ The default GID for this end port.
-
enable_sa_capability
()¶ Enable the SA capability mask. This returns an instance that supports the context manager protocol that should be closed once the SA is finished.
-
gids
= None¶ rdma.devices.DemandList
of all gids
-
lid
¶
-
lid_change
()¶ Called if the port’s LID has changed. Generally from
rdma.ibverbs.Context.handle_async_event()
.
-
lmc
¶
-
phys_state
¶ The port physical state, one of IBA.PHYS_PORT_STATE_*
-
pkey_change
()¶ Called if the port’s pkey list has changed. Generally from
rdma.ibverbs.Context.handle_async_event()
.
-
pkey_index
(pkey)¶ Return the
pkey index
for pkey value pkey.
-
pkeys
= None¶ rdma.devices.DemandList
of all pkeys
-
port_guid
¶
-
port_id
= None¶ Port number
-
rate
¶ A string describing the speed of the port. eg ‘10 Gb/sec (4X)’.
-
sa_path
¶ The path to the SA. This path should only be used for GMPs of class
MAD_SUBNET_ADMIN
and it should never be changed. See IBA 15.4.2.
-
sm_change
()¶ Called if the port’s SM has changed. Generally from
rdma.ibverbs.Context.handle_async_event()
.
-
sm_lid
¶
-
sm_sl
¶
-
state
¶ The port state, one of IBA.PORT_STATE_*
-
subnet_timeout
¶
-
-
class
rdma.devices.
RDMADevice
(name)¶ Bases:
rdma.devices.SysFSCache
A RDMA device. A device has at least one end port. The main significance of a RDMA device in the API is to indicate that multiple end ports can share a single protection domain.
name is the kernel’s name for this device in sysfs.
-
board_id
¶ Device board ID string.
-
end_ports
= None¶ rdma.devices.DemandList
of all end ports
-
fw_ver
¶ Device firmware version string.
-
hca_type
¶ HCA type string.
-
hw_ver
¶ Device hardware version string.
-
name
= None¶ Device’s name
-
node_desc
¶
-
node_guid
¶
-
node_type
¶ The node type, one of IBA.NODE_*.
-
phys_port_count
= 0¶ Number of physical ports
-
sys_image_guid
¶
-
-
class
rdma.devices.
SysFSCache
(dir_)¶ Bases:
object
Cache queries from sysfs attributes. This class is used to make the sysfs parsing demand load.
dir_ is the directory the attributes reside in.
-
rdma.devices.
find_node_guid
(devices, guid)¶ Search the list devices for the device with guid.
Return type: Device
Raises: rdma.RDMAError – If no matching device is found.
-
rdma.devices.
find_port_gid
(devices, gid)¶ Search the list devices for the end port with gid.
Returns: ( EndPort
,gid_index)Raises: rdma.RDMAError – If no matching device is found.
-
rdma.devices.
find_port_guid
(devices, guid)¶ Search the list devices for the end port with guid.
Return type: EndPort
Raises: rdma.RDMAError – If no matching device is found.
-
rdma.devices.
find_port_name
(devices, name)¶ Search the list devices for the end port with name and name may be a device name in which case the first end port is returned, otherwise it may be device/port.
Return type: EndPort
Raises: rdma.RDMAError – If no matching device is found.