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