Class Device
Defined in File device.hpp
Inheritance Relationships
Derived Types
public FileDevice
(Class FileDevice)public FlxDevice
(Class FlxDevice)
Class Documentation
-
class Device
Abstract base class that represents a Felix device. The two implementations are FlxDevice and FileDevice. FlxDevice manages one PCIe endpoint of a physical FELIX card. FileDevice emulates the hardware.
Subclassed by FileDevice, FlxDevice
Public Functions
-
Device(unsigned dev_no, uint8_t vid, uint16_t did, uint16_t cid)
Constructor of abstract class to be used by implementation. The constructor allocates the object, does not interact with hardware.
- Parameters:
dev_no -- Device number, as use dby the flx driver.
vid -- Version of felix resource identifier (fid)
did -- Detector ID of felix resource identifier
cid -- Connect ID of felix resource identifier, maps to the PCIe endpoint
-
virtual int open_device(u_int lock_mask) = 0
Opens the device, maps and reads registers, sets resource locks.
- Parameters:
lock_mask -- to lock resources at driver level
-
virtual void close_device() = 0
Releases the device.
-
virtual bool is_primary() = 0
- Returns:
whether if this PCIe endpoint is the primary, where all registers are available.
-
virtual unsigned int get_card_model() = 0
- Returns:
the card type: 709, 710, 711, 712, 182, 155.
-
virtual unsigned int get_card_endpoints() = 0
- Returns:
number of PCIe endpoints for the card
-
virtual u_int get_regmap_version() = 0
- Returns:
the firmware register map version, read from the register REG_MAP_VERSION
-
inline virtual u_int get_firmware_type()
- Returns:
the firmware type as reported in the register FIRMWARE_MODE
-
virtual u_int get_number_of_channels() = 0
- Returns:
the number of links for the PCie endpoint as reported in the register NUM_OF_CHANNELS
-
virtual bool get_wide_mode() = 0
- Returns:
whether GBT wide mode is used
-
virtual u_int get_block_size() = 0
- Returns:
the ToHost block size as read from the BLOCKSIZE register
-
virtual u_int get_trailer_size() = 0
- Returns:
the ToHost trailer/header size. Derived from CHUNK_TRAILER_32B.
-
virtual flx_fromhost_format get_fromhost_data_format() = 0
- Returns:
the FromHost data format, as in FROMHOST_DATA_FORMAT.
-
virtual flx_tohost_format get_tohost_data_format() = 0
- Returns:
the ToHost data format, as in TOHOST_DATA_FORMAT.
-
virtual int get_fromhost_dmaid() = 0
- Returns:
the identifier of the FromHoist DMA buffer, to be used by felix-toflx.
-
virtual int get_trickle_dmaid() = 0
- Returns:
the identifier of the Trickle configuration DMA buffer.
-
virtual int dma_max_tlp_bytes() = 0
- Returns:
the maximum size supported for a TLP block
-
virtual void set_register(const char *key, uint64_t value) = 0
Set a new value for the given register
- Parameters:
key -- register name
value -- register value
-
virtual uint64_t get_register(const char *key) = 0
Get the current value of the fiven register
- Parameters:
key -- register name
-
virtual bool check_register(const char *key) = 0
- Parameters:
key -- register name
- Returns:
if the given register exists
-
virtual void cancel_irq(int i) = 0
Cancel wait requests for the given MSI-X interrupt
- Parameters:
i -- Interrupt number
-
virtual void irq_wait(int i) = 0
Wait for the given interrupt. This function blocks.
- Parameters:
i -- Interrupt number
-
virtual void irq_enable(int i) = 0
Arm the given interrupt.
- Parameters:
i -- interrupt number
-
virtual void irq_disable(int i) = 0
Disarm the given interrupt.
- Parameters:
i -- interrupt number
-
virtual std::vector<Elink> read_enabled_elinks(int dmaid) = 0
Return the list of enabled e-links for the given DMA id.
- Parameters:
dmaid -- dma buffer identifier
-
std::vector<Elink> get_enabled_elinks_of_type(int dmaid, elink_type_t t)
Return the list of e-links enabled of a given type.
- Parameters:
dmaid -- dma buffer identifier
t -- e-link type e.g. DAQ, DCS, TTC2H...
-
inline unsigned get_device_number()
- Returns:
the device number.
-
unsigned int make_dma_lock_mask(const std::vector<int> &dmaids)
- Parameters:
dmaids -- list of DMA buffers in use
- Returns:
the lock mask for DMA resources
-
u_int get_broadcast_elinks(uint64_t broadcast_elinks[], uint32_t num_of_channels)
- Parameters:
broadcast_elinks -- list of DMA buffers in use
num_of_channels -- list of DMA buffers in use
- Returns:
the number of broadcast e-links
-
bool has_wrong_rm()
Compare the software register map version with hardware one
-
bool is_full_mode()
Firmware does not implement ToHost (lp)GBT e-links
-
bool is_lpgbt_mode()
Firmware implements ToHost (lp)GBT e-links
-
uint64_t get_elink(u_int channel, u_int egroup, u_int epath)
Firmware implements ToHost (lp)GBT e-links
-
uint32_t get_channel(uint32_t elink)
Firmware implements ToHost (lp)GBT e-links
- Parameters:
elink -- elink number
-
uint32_t get_egroup(uint32_t elink)
Firmware implements ToHost (lp)GBT e-links
- Parameters:
is_to_flx -- true if the DMA is a FromHost one
elink -- elink number
-
uint32_t get_epath(uint32_t elink)
Firmware implements ToHost (lp)GBT e-links
-
u_int get_egroups_per_channel(u_int is_to_flx)
Firmware implements ToHost (lp)GBT e-links
- Parameters:
is_to_flx -- true if the DMA is a FromHost one
-
u_int get_epaths_per_egroup(u_int is_to_flx)
Firmware implements ToHost (lp)GBT e-links
- Parameters:
is_to_flx -- true if the DMA is a FromHost one
-
u_int get_ctrl_elinks_per_channel()
Firmware implements ToHost (lp)GBT e-links
-
virtual bool dma_enabled(int dmaid) = 0
- Parameters:
dmaid -- true if the DMA is a FromHost one
- Returns:
true is the DMA buffer is enabled
-
virtual void dma_to_host(DmaBuffer *buf, int dmaid) = 0
set up ToHost (circular) DMA buffer
- Parameters:
dmaid -- DMA buffer number
-
virtual void dma_from_host(DmaBuffer *buf, int dmaid) = 0
set up FromHost (circular) DMA buffer
- Parameters:
dmaid -- DMA buffer number
-
virtual void dma_from_host_trickle(DmaBuffer *buf, int dmaid, size_t config_size) = 0
Set up FromHost (circular) DMA buffer for trickle mode.
- Parameters:
buf -- DMA buffer pointer.
dmaid -- DMA buffer identifier.
config_size -- Size of the trickle configuration message.
-
virtual void dma_set_oneshot(DmaBuffer *buf, int dmaid, size_t config_size) = 0
set up FromHost (non-circular) DMA buffer
- Parameters:
dmaid -- DMA buffer number
-
virtual uint64_t dma_get_fw_ptr(int dmaid) = 0
-
virtual uint64_t dma_get_sw_ptr(int dmaid) = 0
-
virtual void dma_set_sw_ptr(int dmaid, uint64_t p_absolute) = 0
set new value for pointer managed by software (rd for ToHost, wr for FromHost)
- Parameters:
dmaid -- DMA buffer number
p_absolute -- birtual memory address
-
virtual bool dma_cmp_even_bits(int dmaid) = 0
- Parameters:
dmaid -- DMA buffer number
- Returns:
whether sw and fw pointers are have wrapped around the circular buffer the the same number of times.
-
virtual void dma_stop(unsigned int dmaid) = 0
stop DMA buffer data transfer operations
- Parameters:
dmaid -- DMA buffer number
-
virtual monitoring_data_t hw_get_monitoring_data(unsigned int mon_mask = 0xFFF) = 0
- Returns:
hardware monitoring data
Public Static Functions
-
static int64_t broadcast_for(uint64_t elink)
- Parameters:
elink -- list of DMA buffers in use
- Returns:
(?)
-
static int broadcast_type(uint64_t elink)
- Parameters:
elink -- broadcast e-link
- Returns:
the level of broadcast: link, channel, e-liink
-
static const std::string broadcast_type_str(uint64_t elink)
- Parameters:
elink -- broadcast e-link
- Returns:
the level of broadcast: link, channel, e-liink
-
static u_int broadcast_elinks(uint64_t broadcast_elinks[], const uint64_t broadcast_enable_registers[], uint32_t num_of_channels)
read broadcast_elinks and broadcast_enable_registers
- Parameters:
broadcast_elinks -- array of broadcast enabled e-links per link
broadcast_enable_registers -- register values for each link
num_of_channels -- number of device links
- Returns:
the number of broadcast links
-
static const std::string get_elink_type_str(elink_type_t encoding)
Return the e-link type given the encoding used
- Parameters:
encoding -- e-link encoding
Protected Functions
-
virtual uint64_t get_broadcast_enable_gen(u_int channel) = 0
- Parameters:
channel -- the link to be checked
- Returns:
value of BROADCAST_ENABLE_GEN register
-
virtual bool elink_has_stream_id(u_int channel, u_int egroup, u_int epath) = 0
Check if the e-link has streams enabled
- Parameters:
channel -- (lp)GBT link
egroup -- (lp)GBT e-group
epath -- (lp)GBT e-path
Protected Attributes
-
unsigned m_device_number
-
uint8_t m_vid
-
uint16_t m_did
-
uint16_t m_cid
-
u_int m_firmware_type
-
flx_fromhost_format m_fromHostDataFormat = {UN_INITIALIZED}
-
flx_tohost_format m_toHostDataFormat = {TOHOST_SUBCHUNK_TRAILER}
-
Device(unsigned dev_no, uint8_t vid, uint16_t did, uint16_t cid)