Line data Source code
1 : #ifndef FELIX_FROMHOST_MONITOR_H_
2 : #define FELIX_FROMHOST_MONITOR_H_
3 :
4 : #include "monitor.hpp"
5 : #include <cstdint>
6 :
7 :
8 : /**
9 : * Monitoring info for one Device.
10 : */
11 : struct FromHostDeviceStats
12 : {
13 : int device_id;
14 :
15 22 : explicit FromHostDeviceStats(int d)
16 22 : : device_id(d) {};
17 : };
18 :
19 :
20 : /**
21 : * Data structure for the monitoring of a FromHost DMA buffer.
22 : * */
23 : struct FromHostDmaStats
24 : {
25 : int dmaid;
26 : uint32_t dma_free_MB;
27 : uint64_t msg_counter;
28 : float msg_rate_Hz;
29 : uint64_t bytes_counter;
30 : float msg_rate_Mbps;
31 : struct timespec ts;
32 :
33 : FromHostDmaStats get_increment(FromHostDmaStats & stats);
34 :
35 10 : FromHostDmaStats()
36 10 : : dmaid(0), dma_free_MB(0), msg_counter(0), msg_rate_Hz(0), bytes_counter(0), msg_rate_Mbps(0)
37 : {
38 10 : clock_gettime(CLOCK_MONOTONIC_RAW , &ts);
39 10 : };
40 :
41 1 : explicit FromHostDmaStats(uint32_t d, uint32_t MB, uint64_t msg, uint64_t bytes)
42 1 : : dmaid(d), dma_free_MB(MB), msg_counter(msg), msg_rate_Hz(0), bytes_counter(bytes), msg_rate_Mbps(0)
43 : {
44 1 : clock_gettime(CLOCK_MONOTONIC_RAW , &ts);
45 : };
46 : };
47 :
48 :
49 : /**
50 : * Data structure for the monitoring of a FromHost writer.
51 : * Multiple writers can share the same FromHost buffers.
52 : * */
53 : struct FromHostWriterStats
54 : {
55 : int writer_id;
56 : char type;
57 : unsigned int number_of_connections;
58 :
59 22 : explicit FromHostWriterStats(int wi, char t, uint32_t s) :
60 22 : writer_id(wi),
61 22 : type(t),
62 22 : number_of_connections(s) { };
63 : };
64 :
65 :
66 : /**
67 : * Data structure for the monitoring of a FromHost e-link.
68 : * */
69 : struct FromHostElinkStats
70 : {
71 : uint64_t fid = 0;
72 : uint64_t processed_msg = 0;
73 : uint64_t processed_bytes = 0;
74 : uint64_t largest_msg_size = 0;
75 : float rate_msg_Hz = 0;
76 : float rate_msg_Mbps = 0;
77 : uint64_t dropped_msg = 0;
78 : struct timespec ts;
79 :
80 : void on_processed_msg(uint32_t size_bytes);
81 : FromHostElinkStats get_increment(FromHostElinkStats & stats);
82 21 : FromHostElinkStats() = default;
83 :
84 27 : explicit FromHostElinkStats(uint64_t f) : fid(f), processed_msg(0), processed_bytes(0),
85 27 : largest_msg_size(0), rate_msg_Hz(0), rate_msg_Mbps(0), dropped_msg(0)
86 : {
87 27 : clock_gettime(CLOCK_MONOTONIC_RAW , &ts);
88 27 : };
89 : };
90 :
91 :
92 : /**
93 : * Data structure for the monitoring FromHost transfers of a device.
94 : * It contains information about the DMA buffer, the associated writers and
95 : * the e-links served by each writer.
96 : * */
97 1 : class FromHostMonitor : public Monitor
98 : {
99 : public:
100 6 : explicit FromHostMonitor(std::string& fifoname) : Monitor(fifoname) {
101 6 : }
102 : //These functions are called in a nested loop with hierarchy
103 : //devices > dmas > writers > elinks.
104 : void append_device_stats(const std::string& ts, const std::string& hostname, const FromHostDeviceStats & s);
105 : void append_dma_stats(const std::string& ts, const std::string& hostname, int deviceid, const FromHostDmaStats & s);
106 : void append_writer_stats(const std::string& ts, const std::string& hostname, int deviceid, int dma_id, const FromHostWriterStats & s);
107 : void append_elink_stats(const std::string& ts, const std::string& hostname, int device, int dma_id, int reader_id, const FromHostElinkStats & s);
108 : };
109 :
110 : #endif /* FELIX_FROMHOST_MONITOR_H_ */
|