FD.io VPP  v19.01.3-6-g70449b9b9
Vector Packet Processing
bond_group_binding.hpp
Go to the documentation of this file.
1 /*
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:
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_BOND_GROUP_BINDING_H__
17 #define __VOM_BOND_GROUP_BINDING_H__
18 
19 #include <set>
20 
21 #include "vom/bond_interface.hpp"
22 #include "vom/bond_member.hpp"
23 #include "vom/hw.hpp"
24 #include "vom/inspect.hpp"
25 #include "vom/interface.hpp"
26 #include "vom/object_base.hpp"
27 #include "vom/om.hpp"
28 #include "vom/singular_db.hpp"
29 
30 namespace VOM {
31 /**
32  * A representation of bond interface binding
33  */
35 {
36 public:
37  /**
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
41  */
42  typedef std::string key_t;
43 
44  /**
45  * The container type for enslaved itfs
46  */
47  typedef std::set<bond_member> enslaved_itf_t;
48 
49  /**
50  * Construct a new object matching the desried state
51  */
52  bond_group_binding(const bond_interface& itf, const enslaved_itf_t& mem);
53 
54  /**
55  * Copy Constructor
56  */
58 
59  /**
60  * Destructor
61  */
63 
64  /**
65  * Return the 'singular' of the bond interface binding that matches this
66  * object
67  */
68  std::shared_ptr<bond_group_binding> singular() const;
69 
70  /**
71  * convert to string format for debug purposes
72  */
73  std::string to_string() const;
74 
75  /**
76  * get the key to this object
77  */
78  const key_t key() const;
79 
80  /**
81  * Dump all bond interface bindings into the stream provided
82  */
83  static void dump(std::ostream& os);
84 
85 private:
86  /**
87  * Class definition for listeners to OM events
88  */
90  {
91  public:
92  event_handler();
93  virtual ~event_handler() = default;
94 
95  /**
96  * Handle a populate event
97  */
98  void handle_populate(const client_db::key_t& key);
99 
100  /**
101  * Handle a replay event
102  */
103  void handle_replay();
104 
105  /**
106  * Show the object in the Singular DB
107  */
108  void show(std::ostream& os);
109 
110  /**
111  * Get the sortable Id of the listener
112  */
113  dependency_t order() const;
114  };
115 
116  /**
117  * event_handler to register with OM
118  */
119  static event_handler m_evh;
120 
121  /**
122  * Enqueue command to the VPP command Q for the update
123  */
124  void update(const bond_group_binding& obj);
125 
126  /**
127  * Find or add bond interface binding to the OM
128  */
129  static std::shared_ptr<bond_group_binding> find_or_add(
130  const bond_group_binding& temp);
131 
132  /*
133  * It's the OM class that calls singular()
134  */
135  friend class OM;
136 
137  /**
138  * It's the singular_db class that calls replay()
139  */
140  friend class singular_db<key_t, bond_group_binding>;
141 
142  /**
143  * Sweep/reap the object if still stale
144  */
145  void sweep(void);
146 
147  /**
148  * replay the object to create it in hardware
149  */
150  void replay(void);
151 
152  /**
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
156  */
157  std::shared_ptr<bond_interface> m_itf;
158 
159  /**
160  * A list of member interfaces.
161  */
162  const enslaved_itf_t m_mem_itfs;
163 
164  /**
165  * HW configuration for the binding. The bool representing the
166  * do/don't bind.
167  */
168  HW::item<bool> m_binding;
169 
170  /**
171  * A map of all bond interface bindings keyed against the interface +
172  * "binding".
173  */
175 };
176 };
177 
178 /*
179  * fd.io coding-style-patch-verification: ON
180  *
181  * Local Variables:
182  * eval: (c-set-style "mozilla")
183  * End:
184  */
185 
186 #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 key_t key() const
get the key to this object
std::shared_ptr< bond_group_binding > singular() const
Return the &#39;singular&#39; of the bond interface binding that matches this object.
A representation of bond interface binding.
bond_group_binding(const bond_interface &itf, const enslaved_itf_t &mem)
Construct a new object matching the desried state.
A Database to store the unique &#39;singular&#39; instances of a single object type.
Definition: singular_db.hpp:33
static void dump(std::ostream &os)
Dump all bond interface bindings into the stream provided.
A bond-interface.
std::set< bond_member > enslaved_itf_t
The container type for enslaved itfs.
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:340
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 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
std::string to_string() const
convert to string format for debug purposes
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
void * mem
std::string key_t
The KEY can be used to uniquely identify the Bond Binding.