bmv2
Designing your own switch target with bmv2
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ageing.h
1 /* Copyright 2013-present Barefoot Networks, Inc.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /*
17  * Antonin Bas (antonin@barefootnetworks.com)
18  *
19  */
20 
21 #ifndef BM_BM_SIM_AGEING_H_
22 #define BM_BM_SIM_AGEING_H_
23 
24 #include <memory>
25 #include <string>
26 
27 #include "device_id.h"
28 #include "named_p4object.h"
29 #include "transport.h"
30 
31 namespace bm {
32 
33 class MatchTableAbstract;
34 
35 class AgeingMonitorIface {
36  public:
37  // the header size for notifications is always 32 bytes
38  struct msg_hdr_t {
39  char sub_topic[4];
40  s_device_id_t switch_id;
41  s_cxt_id_t cxt_id;
42  uint64_t buffer_id;
43  int table_id;
44  unsigned int num_entries;
45  } __attribute__((packed));
46 
47  virtual ~AgeingMonitorIface() { }
48 
49  virtual void add_table(MatchTableAbstract *table) = 0;
50 
51  virtual void set_sweep_interval(unsigned int ms) = 0;
52 
53  virtual unsigned int get_sweep_interval() = 0;
54 
55  virtual void reset_state() = 0;
56 
62  virtual std::string get_table_name_from_id(p4object_id_t id) const = 0;
63 
64  static std::unique_ptr<AgeingMonitorIface> make(
65  device_id_t device_id, cxt_id_t cxt_id,
66  std::shared_ptr<TransportIface> writer,
67  unsigned int sweep_interval_ms = 1000u);
68 };
69 
70 } // namespace bm
71 
72 #endif // BM_BM_SIM_AGEING_H_
named_p4object.h