2 * Copyright (c) 2018 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_BOND_GROUP_BINDING_H__
17 #define __VOM_BOND_GROUP_BINDING_H__
21 #include "vom/bond_interface.hpp"
22 #include "vom/bond_member.hpp"
24 #include "vom/inspect.hpp"
25 #include "vom/interface.hpp"
26 #include "vom/object_base.hpp"
28 #include "vom/singular_db.hpp"
32 * A representation of bond interface binding
34 class bond_group_binding : public object_base
38 * The KEY can be used to uniquely identify the Bond Binding.
39 * (other choices for keys, like the summation of the properties
40 * of the rules, are rather too cumbersome to use
42 typedef std::string key_t;
45 * The container type for enslaved itfs
47 typedef std::set<bond_member> enslaved_itf_t;
50 * Construct a new object matching the desried state
52 bond_group_binding(const bond_interface& itf, const enslaved_itf_t& mem);
57 bond_group_binding(const bond_group_binding& o);
62 ~bond_group_binding();
65 * Return the 'singular' of the bond interface binding that matches this
68 std::shared_ptr<bond_group_binding> singular() const;
71 * convert to string format for debug purposes
73 std::string to_string() const;
76 * get the key to this object
78 const key_t key() const;
81 * Dump all bond interface bindings into the stream provided
83 static void dump(std::ostream& os);
87 * Class definition for listeners to OM events
89 class event_handler : public OM::listener, public inspect::command_handler
93 virtual ~event_handler() = default;
96 * Handle a populate event
98 void handle_populate(const client_db::key_t& key);
101 * Handle a replay event
103 void handle_replay();
106 * Show the object in the Singular DB
108 void show(std::ostream& os);
111 * Get the sortable Id of the listener
113 dependency_t order() const;
117 * event_handler to register with OM
119 static event_handler m_evh;
122 * Enqueue command to the VPP command Q for the update
124 void update(const bond_group_binding& obj);
127 * Find or add bond interface binding to the OM
129 static std::shared_ptr<bond_group_binding> find_or_add(
130 const bond_group_binding& temp);
133 * It's the OM class that calls singular()
138 * It's the singular_db class that calls replay()
140 friend class singular_db<key_t, bond_group_binding>;
143 * Sweep/reap the object if still stale
148 * replay the object to create it in hardware
153 * A reference counting pointer to the bond interface.
154 * By holding the reference here, we can guarantee that
155 * this object will outlive the interface
157 std::shared_ptr<bond_interface> m_itf;
160 * A list of member interfaces.
162 const enslaved_itf_t m_mem_itfs;
165 * HW configuration for the binding. The bool representing the
168 HW::item<bool> m_binding;
171 * A map of all bond interface bindings keyed against the interface +
174 static singular_db<key_t, bond_group_binding> m_db;
179 * fd.io coding-style-patch-verification: ON
182 * eval: (c-set-style "mozilla")