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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef __VOM_QOS_MARK_H__
17 #define __VOM_QOS_MARK_H__
21 #include "vom/interface.hpp"
22 #include "vom/qos_map.hpp"
23 #include "vom/qos_types.hpp"
24 #include "vom/singular_db.hpp"
30 * The marking of packets with QoS bits as they egress an interface
32 class mark : public object_base
35 mark(const interface& i, const map& m, const source_t& source);
40 typedef std::pair<interface::key_t, source_t> key_t;
43 * Return the object's key
45 const key_t key() const;
50 bool operator==(const mark& bdae) const;
53 * Return the matching 'singular instance'
55 std::shared_ptr<mark> singular() const;
58 * Find the instnace of the bridge_domain domain in the OM
60 static std::shared_ptr<mark> find(const key_t& k);
63 * Dump all bridge_domain-doamin into the stream provided
65 static void dump(std::ostream& os);
68 * replay the object to create it in hardware
73 * Convert to string for debugging
75 std::string to_string() const;
79 * Class definition for listeners to OM events
81 class event_handler : public OM::listener, public inspect::command_handler
85 virtual ~event_handler() = default;
88 * Handle a populate event
90 void handle_populate(const client_db::key_t& key);
93 * Handle a replay event
98 * Show the object in the Singular DB
100 void show(std::ostream& os);
103 * Get the sortable Id of the listener
105 dependency_t order() const;
109 * event_handler to register with OM
111 static event_handler m_evh;
114 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
116 void update(const mark& obj);
119 * Find or add the instnace of the bridge_domain domain in the OM
121 static std::shared_ptr<mark> find_or_add(const mark& temp);
124 * It's the VPPHW class that updates the objects in HW
126 friend class VOM::OM;
129 * It's the singular_db class that calls replay()
131 friend class singular_db<key_t, mark>;
134 * Sweep/reap the object if still stale
139 * HW configuration for the config. The bool representing the
140 * do/don't configured/unconfigured.
142 HW::item<bool> m_config;
145 * The interface the mark applies to
147 std::shared_ptr<interface> m_itf;
150 * The map the marking uses
152 std::shared_ptr<map> m_map;
155 * QoS source to mark from
160 * A map of all QoS Markers
162 static singular_db<key_t, mark> m_db;
167 std::ostream& operator<<(std::ostream& os, const QoS::mark::key_t& key);
172 * fd.io coding-style-patch-verification: ON
175 * eval: (c-set-style "mozilla")