FD.io VPP  v19.08.3-2-gbabecb413
Vector Packet Processing
qos_record.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 Cisco and/or its affiliates.
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 #ifndef __VOM_QOS_RECORD_H__
17 #define __VOM_QOS_RECORD_H__
18 
19 #include <ostream>
20 
21 #include "vom/interface.hpp"
22 #include "vom/qos_types.hpp"
23 #include "vom/singular_db.hpp"
24 
25 namespace VOM {
26 /**
27  * Types belonging to QoS
28  */
29 namespace QoS {
30 
31 class record : public object_base
32 {
33 public:
34  record(const interface& i, const source_t& source);
35  record(const record& r);
36 
37  ~record();
38 
39  typedef std::pair<interface::key_t, source_t> key_t;
40 
41  /**
42  * Return the object's key
43  */
44  const key_t key() const;
45 
46  /**
47  * comparison operator
48  */
49  bool operator==(const record& bdae) const;
50 
51  /**
52  * Return the matching 'singular instance'
53  */
54  std::shared_ptr<record> singular() const;
55 
56  /**
57  * Find the instnace of the bridge_domain domain in the OM
58  */
59  static std::shared_ptr<record> find(const key_t& k);
60 
61  /**
62  * Dump all bridge_domain-doamin into the stream provided
63  */
64  static void dump(std::ostream& os);
65 
66  /**
67  * replay the object to create it in hardware
68  */
69  void replay(void);
70 
71  /**
72  * Convert to string for debugging
73  */
74  std::string to_string() const;
75 
76 private:
77  /**
78  * Class definition for listeners to OM events
79  */
81  {
82  public:
83  event_handler();
84  virtual ~event_handler() = default;
85 
86  /**
87  * Handle a populate event
88  */
89  void handle_populate(const client_db::key_t& key);
90 
91  /**
92  * Handle a replay event
93  */
94  void handle_replay();
95 
96  /**
97  * Show the object in the Singular DB
98  */
99  void show(std::ostream& os);
100 
101  /**
102  * Get the sortable Id of the listener
103  */
104  dependency_t order() const;
105  };
106 
107  /**
108  * event_handler to register with OM
109  */
110  static event_handler m_evh;
111 
112  /**
113  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
114  */
115  void update(const record& obj);
116 
117  /**
118  * Find or add the instnace of the bridge_domain domain in the OM
119  */
120  static std::shared_ptr<record> find_or_add(const record& temp);
121 
122  /*
123  * It's the VPPHW class that updates the objects in HW
124  */
125  friend class VOM::OM;
126 
127  /**
128  * It's the singular_db class that calls replay()
129  */
130  friend class singular_db<key_t, record>;
131 
132  /**
133  * Sweep/reap the object if still stale
134  */
135  void sweep(void);
136 
137  /**
138  * HW configuration for the config. The bool representing the
139  * do/don't configured/unconfigured.
140  */
141  HW::item<bool> m_config;
142 
143  /**
144  * The interface the endpoint is attached to.
145  */
146  std::shared_ptr<interface> m_itf;
147 
148  /**
149  * QoS source to record from
150  */
151  source_t m_src;
152 
153  /**
154  * A map of all bridge_domains
155  */
156  static singular_db<key_t, record> m_db;
157 };
158 
159 }; // namesapce QoS
160 
161 std::ostream& operator<<(std::ostream& os, const QoS::record::key_t& key);
162 
163 }; // namespace VOM
164 
165 /*
166  * fd.io coding-style-patch-verification: ON
167  *
168  * Local Variables:
169  * eval: (c-set-style "mozilla")
170  * End:
171  */
172 
173 #endif
std::pair< interface::key_t, source_t > key_t
Definition: qos_record.hpp:39
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
Definition: client_db.hpp:51
int i
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
Definition: qos_record.cpp:114
void replay(void)
replay the object to create it in hardware
Definition: qos_record.cpp:71
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
record(const interface &i, const source_t &source)
Definition: qos_record.cpp:29
std::string to_string() const
Convert to string for debugging.
Definition: qos_record.cpp:79
A representation of an interface in VPP.
Definition: interface.hpp:41
Class definition for listeners to OM events.
Definition: om.hpp:284
inspect command handler Handler
Definition: inspect.hpp:54
The Source of the QoS classification (i.e.
Definition: qos_types.hpp:33
void event_handler(void *tls_async)
Definition: tls_async.c:338
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
Definition: types.hpp:43
The interface to writing objects into VPP OM.
Definition: om.hpp:140
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
std::ostream & operator<<(std::ostream &os, const std::pair< direction_t, interface::key_t > &key)
std::shared_ptr< record > singular() const
Return the matching &#39;singular instance&#39;.
Definition: qos_record.cpp:108
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
const key_t key() const
Return the object&#39;s key.
Definition: qos_record.cpp:50
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
static std::shared_ptr< record > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.
Definition: qos_record.cpp:102
bool operator==(const record &bdae) const
comparison operator
Definition: qos_record.cpp:56