bmv2
Designing your own switch target with bmv2
|
Go to the documentation of this file.
35 #ifndef BM_BM_SIM_COUNTERS_H_
36 #define BM_BM_SIM_COUNTERS_H_
58 enum CounterErrorCode {
74 CounterErrorCode reset_counter();
80 void serialize(std::ostream *out)
const;
81 void deserialize(std::istream *in);
84 std::atomic<std::uint_fast64_t> bytes{0u};
85 std::atomic<std::uint_fast64_t> packets{0u};
88 using meter_array_id_t = p4object_id_t;
102 using CounterErrorCode = Counter::CounterErrorCode;
104 using iterator = std::vector<Counter>::iterator;
105 using const_iterator = std::vector<Counter>::const_iterator;
111 CounterErrorCode reset_counters();
115 return counters[idx];
120 return counters[idx];
125 assert(idx <
size());
126 return counters[idx];
131 assert(idx <
size());
132 return counters[idx];
138 iterator
begin() {
return counters.begin(); }
141 const_iterator
begin()
const {
return counters.begin(); }
144 iterator
end() {
return counters.end(); }
147 const_iterator
end()
const {
return counters.end(); }
150 size_t size()
const {
return counters.size(); }
152 void reset_state() { reset_counters(); }
155 std::vector<Counter> counters;
160 #endif // BM_BM_SIM_COUNTERS_H_
Definition: named_p4object.h:39
void increment_counter(const Packet &pkt)
Increments both counter values (bytes and packets)
Definition: counters.h:66
uint64_t counter_value_t
A counter value (measuring bytes or packets) is a uint64_t.
Definition: counters.h:56
Counter & operator[](size_t idx)
Access the counter at position idx, asserts if bad idx.
Definition: counters.h:124
iterator begin()
NC.
Definition: counters.h:138
iterator end()
NC.
Definition: counters.h:144
const Counter & get_counter(size_t idx) const
Access the counter at position idx, asserts if bad idx.
Definition: counters.h:119
const_iterator begin() const
NC.
Definition: counters.h:141
Definition: counters.h:53
int get_ingress_length() const
Definition: packet.h:151
size_t size() const
Return the size of the CounterArray (i.e. number of counters it includes)
Definition: counters.h:150
const_iterator end() const
NC.
Definition: counters.h:147
Counter & get_counter(size_t idx)
Access the counter at position idx, asserts if bad idx.
Definition: counters.h:114
const Counter & operator[](size_t idx) const
Access the counter at position idx, asserts if bad idx.
Definition: counters.h:130
Definition: counters.h:100