Line data Source code
1 : #ifndef L0ID_DECODER_H_ 2 : #define L0ID_DECODER_H_ 3 : 4 : #include "block.hpp" 5 : #include <functional> 6 : #include <vector> 7 : #include <sys/uio.h> 8 : 9 : #include "felix/felix_fid.h" 10 : 11 600 : inline bool is_ttc2h_elink(uint64_t fid) 12 : { 13 600 : uint32_t elink = get_elink(fid); 14 : #if REGMAP_VERSION < 0x0500 15 : if (elink == 315 || elink == 827 || elink == 1537 || elink == 0x600){ 16 : #else 17 600 : if (elink == 0x600){ 18 : #endif 19 : return true; 20 : } else { 21 0 : return false; 22 : } 23 : } 24 : 25 : enum L0ID_FMT { 26 : TTC2H = 1, LATOME = 2, FMEMU = 3, FELIG = 4, NSW_VMM = 5, NSW_TP = 6 27 : }; 28 : 29 : /** 30 : * Check of L0ID sequentiality 31 : * 32 : * The L0Decoder class is capable of retrieving the L0ID (and BCID for TTC2H 33 : * link) and verify it increases sequentially across chunks. 34 : * 35 : */ 36 50 : class L0Decoder 37 : { 38 : public: 39 : L0Decoder(int format, uint64_t fid); 40 : 41 : /** 42 : * @brief Check L0ID sequence of the passed chunk 43 : * @param data The iov vector used by Decoder to store a chunk. 44 : * @return true in when out-of-sequence L0ID is detected. 45 : */ 46 : std::function<bool(const uint8_t* data, size_t len)> check_sequence_error; 47 : 48 : /** 49 : * @brief Assemble the necessary chunk bytes and calls check_sequence_error 50 : * @param data the iovec vector of subchunks 51 : * @return whether the sequence check is passed or not. 52 : */ 53 : bool check_tohost_chunk(std::vector<iovec> const &data); 54 : 55 : /** 56 : * @return Last L0ID processed. 57 : */ 58 600 : xl1id_t get_last(){return m_last;} 59 : 60 : /** 61 : * @return Mask of L0ID event counter. 62 : */ 63 600 : uint32_t get_ec_mask(){return m_ec_mask;} 64 : 65 : private: 66 : uint64_t m_fid; 67 : xl1id_t m_last; 68 : uint32_t m_required_bytes; 69 : uint32_t m_ec_mask; 70 : 71 : /** @brief Printout of error message */ 72 : bool compare(xl1id_t current, xl1id_t expected); 73 : 74 : bool check_sequence_ttc2h( const uint8_t* data, size_t len); 75 : bool check_sequence_latome( const uint8_t* data, size_t len); 76 : bool check_sequence_fmemu( const uint8_t* data, size_t len); 77 : bool check_sequence_felig( const uint8_t* data, size_t len); 78 : bool check_sequence_nsw_vmm(const uint8_t* data, size_t len); 79 : bool check_sequence_nsw_tp( const uint8_t* data, size_t len); 80 : }; 81 : 82 : #endif /* L0ID_DECODER_H_ */