FD.io VPP  v21.01.1
Vector Packet Processing
qos_map.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_MAP_H__
17 #define __VOM_QOS_MAP_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 /**
32  * A QoS map determines how value from one source are translated to
33  * values of another source
34  */
35 class map : public object_base
36 {
37 public:
38  typedef std::array<std::array<bits_t, 256>, 4> outputs_t;
39 
40  map(uint32_t id, const outputs_t& o);
41  map(const map& r);
42 
43  ~map();
44 
45  typedef uint32_t key_t;
46 
47  /**
48  * Return the object's key
49  */
50  const key_t key() const;
51 
52  /**
53  * Return the object's ID
54  */
55  const key_t id() const;
56 
57  /**
58  * comparison operator
59  */
60  bool operator==(const map& bdae) const;
61 
62  /**
63  * Return the matching 'singular instance'
64  */
65  std::shared_ptr<map> singular() const;
66 
67  /**
68  * Find the instnace of the bridge_domain domain in the OM
69  */
70  static std::shared_ptr<map> find(const key_t& k);
71 
72  /**
73  * Dump all bridge_domain-doamin into the stream provided
74  */
75  static void dump(std::ostream& os);
76 
77  /**
78  * replay the object to create it in hardware
79  */
80  void replay(void);
81 
82  /**
83  * Convert to string for debugging
84  */
85  std::string to_string() const;
86 
87 private:
88  /**
89  * Class definition for listeners to OM events
90  */
92  {
93  public:
94  event_handler();
95  virtual ~event_handler() = default;
96 
97  /**
98  * Handle a populate event
99  */
100  void handle_populate(const client_db::key_t& key);
101 
102  /**
103  * Handle a replay event
104  */
105  void handle_replay();
106 
107  /**
108  * Show the object in the Singular DB
109  */
110  void show(std::ostream& os);
111 
112  /**
113  * Get the sortable Id of the listener
114  */
115  dependency_t order() const;
116  };
117 
118  /**
119  * event_handler to register with OM
120  */
121  static event_handler m_evh;
122 
123  /**
124  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
125  */
126  void update(const map& obj);
127 
128  /**
129  * Find or add the instnace of the bridge_domain domain in the OM
130  */
131  static std::shared_ptr<map> find_or_add(const map& temp);
132 
133  /*
134  * It's the VPPHW class that updates the objects in HW
135  */
136  friend class VOM::OM;
137 
138  /**
139  * It's the singular_db class that calls replay()
140  */
141  friend class singular_db<key_t, map>;
142 
143  /**
144  * Sweep/reap the object if still stale
145  */
146  void sweep(void);
147 
148  /**
149  * HW configuration for the config. The bool representing the
150  * do/don't configured/unconfigured.
151  */
152  HW::item<bool> m_config;
153 
154  /**
155  * unique ID of the MAP.
156  */
157  uint32_t m_id;
158 
159  /**
160  * outputs from the translation
161  */
162  outputs_t m_outputs;
163 
164  /**
165  * A map of all bridge_domains
166  */
167  static singular_db<key_t, map> m_db;
168 };
169 
170 }; // namesapce QoS
171 
172 }; // namespace VOM
173 
174 /*
175  * fd.io coding-style-patch-verification: OFF
176  *
177  * Local Variables:
178  * eval: (c-set-style "mozilla")
179  * End:
180  */
181 
182 #endif
static std::shared_ptr< map > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.
Definition: qos_map.cpp:110
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
Definition: qos_map.cpp:122
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
const key_t key() const
Return the object&#39;s key.
Definition: qos_map.cpp:50
const key_t id() const
Return the object&#39;s ID.
Definition: qos_map.cpp:56
const char *const string
Definition: cJSON.h:172
uint32_t key_t
Definition: qos_map.hpp:45
bool operator==(const map &bdae) const
comparison operator
Definition: qos_map.cpp:62
std::shared_ptr< map > singular() const
Return the matching &#39;singular instance&#39;.
Definition: qos_map.cpp:116
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
std::array< std::array< bits_t, 256 >, 4 > outputs_t
Definition: qos_map.hpp:38
Class definition for listeners to OM events.
Definition: om.hpp:284
inspect command handler Handler
Definition: inspect.hpp:54
void event_handler(void *tls_async)
Definition: tls_async.c:334
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 QoS map determines how value from one source are translated to values of another source...
Definition: qos_map.hpp:35
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
void show(char *chroot_path, int verbose)
Definition: svmtool.c:104
std::string to_string() const
Convert to string for debugging.
Definition: qos_map.cpp:85
void replay(void)
replay the object to create it in hardware
Definition: qos_map.cpp:77
map(uint32_t id, const outputs_t &o)
Definition: qos_map.cpp:29