FD.io VPP  v21.01.1
Vector Packet Processing
qos_store.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_STORE_H__
17 #define __VOM_QOS_STORE_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 store : public object_base
32 {
33 public:
34  store(const interface& i, const source_t& source, bits_t value);
35  store(const store& r);
36 
37  ~store();
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 store& bdae) const;
50 
51  /**
52  * Return the matching 'singular instance'
53  */
54  std::shared_ptr<store> singular() const;
55 
56  /**
57  * Find the instnace of the bridge_domain domain in the OM
58  */
59  static std::shared_ptr<store> 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 store& obj);
116 
117  /**
118  * Find or add the instnace of the bridge_domain domain in the OM
119  */
120  static std::shared_ptr<store> find_or_add(const store& 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, store>;
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 store from
150  */
151  source_t m_src;
152 
153  /**
154  * QoS Value to store in the buffer
155  */
156  bits_t m_value;
157 
158  /**
159  * A map of all bridge_domains
160  */
161  static singular_db<key_t, store> m_db;
162 };
163 
164 }; // namesapce QoS
165 
166 std::ostream& operator<<(std::ostream& os, const QoS::store::key_t& key);
167 
168 }; // namespace VOM
169 
170 /*
171  * fd.io coding-style-patch-verification: OFF
172  *
173  * Local Variables:
174  * eval: (c-set-style "mozilla")
175  * End:
176  */
177 
178 #endif
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
Definition: qos_store.cpp:119
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_store.cpp:52
const char *const string
Definition: cJSON.h:172
std::shared_ptr< store > singular() const
Return the matching &#39;singular instance&#39;.
Definition: qos_store.cpp:113
std::pair< interface::key_t, source_t > key_t
Definition: qos_store.hpp:39
static std::shared_ptr< store > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.
Definition: qos_store.cpp:107
uint8_t bits_t
Definition: qos_types.hpp:27
store(const interface &i, const source_t &source, bits_t value)
Definition: qos_store.cpp:29
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
void replay(void)
replay the object to create it in hardware
Definition: qos_store.cpp:73
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
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: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
u8 value
Definition: qos.api:54
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)
bool operator==(const store &bdae) const
comparison operator
Definition: qos_store.cpp:58
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
std::string to_string() const
Convert to string for debugging.
Definition: qos_store.cpp:82
void show(char *chroot_path, int verbose)
Definition: svmtool.c:104