FD.io VPP  v19.04.2-12-g66b1689
Vector Packet Processing
gbp_endpoint_group.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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_GBP_ENDPOINT_GROUP_H__
17 #define __VOM_GBP_ENDPOINT_GROUP_H__
18 
19 #include "vom/interface.hpp"
20 #include "vom/singular_db.hpp"
21 #include "vom/types.hpp"
22 
24 #include "vom/gbp_route_domain.hpp"
25 
26 namespace VOM {
27 
28 /**
29  * EPG IDs are 32 bit integers
30  */
31 typedef uint32_t vnid_t;
32 typedef uint16_t sclass_t;
33 
34 /**
35  * A entry in the ARP termination table of a Bridge Domain
36  */
38 {
39 public:
40  /**
41  * Endpoint Retention Policy Settings
42  */
43  struct retention_t
44  {
45  retention_t();
47 
48  retention_t(const retention_t&) = default;
49  retention_t& operator=(const retention_t&) = default;
50 
51  bool operator==(const retention_t& o) const;
52  std::string to_string() const;
53 
54  /**
55  * Remote Endpoint timeout/ageing
56  */
58  };
59 
60  /**
61  * The key for a GBP endpoint group is its ID
62  */
63  typedef sclass_t key_t;
64 
65  /**
66  * Construct a GBP endpoint_group
67  */
68  gbp_endpoint_group(vnid_t vnid,
69  sclass_t sclass,
70  const interface& itf,
71  const gbp_route_domain& rd,
72  const gbp_bridge_domain& bd);
73  gbp_endpoint_group(vnid_t vnid,
74  sclass_t sclass,
75  const gbp_route_domain& rd,
76  const gbp_bridge_domain& bd);
77  gbp_endpoint_group(sclass_t sclass,
78  const gbp_route_domain& rd,
79  const gbp_bridge_domain& bd);
80 
81  /**
82  * Copy Construct
83  */
85 
86  /**
87  * Destructor
88  */
90 
91  /**
92  * Return the object's key
93  */
94  const key_t key() const;
95 
96  /**
97  * comparison operator
98  */
99  bool operator==(const gbp_endpoint_group& bdae) const;
100 
101  /**
102  * Return the matching 'singular instance'
103  */
104  std::shared_ptr<gbp_endpoint_group> singular() const;
105 
106  /**
107  * Find the instnace of the bridge_domain domain in the OM
108  */
109  static std::shared_ptr<gbp_endpoint_group> find(const key_t& k);
110 
111  /**
112  * Dump all bridge_domain-doamin into the stream provided
113  */
114  static void dump(std::ostream& os);
115 
116  /**
117  * replay the object to create it in hardware
118  */
119  void replay(void);
120 
121  /**
122  * Convert to string for debugging
123  */
124  std::string to_string() const;
125 
126  /**
127  * Get the ID of the EPG
128  */
129  vnid_t vnid() const;
130  sclass_t sclass() const;
131 
132  const std::shared_ptr<gbp_route_domain> get_route_domain() const;
133  const std::shared_ptr<gbp_bridge_domain> get_bridge_domain() const;
134 
135  void set(const retention_t& retention);
136 
137 private:
138  /**
139  * Class definition for listeners to OM events
140  */
142  {
143  public:
144  event_handler();
145  virtual ~event_handler() = default;
146 
147  /**
148  * Handle a populate event
149  */
150  void handle_populate(const client_db::key_t& key);
151 
152  /**
153  * Handle a replay event
154  */
155  void handle_replay();
156 
157  /**
158  * Show the object in the Singular DB
159  */
160  void show(std::ostream& os);
161 
162  /**
163  * Get the sortable Id of the listener
164  */
165  dependency_t order() const;
166  };
167 
168  /**
169  * event_handler to register with OM
170  */
171  static event_handler m_evh;
172 
173  /**
174  * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
175  */
176  void update(const gbp_endpoint_group& obj);
177 
178  /**
179  * Find or add the instnace of the bridge_domain domain in the OM
180  */
181  static std::shared_ptr<gbp_endpoint_group> find_or_add(
182  const gbp_endpoint_group& temp);
183 
184  /*
185  * It's the VPPHW class that updates the objects in HW
186  */
187  friend class OM;
188 
189  /**
190  * It's the singular_db class that calls replay()
191  */
192  friend class singular_db<key_t, gbp_endpoint_group>;
193 
194  /**
195  * Sweep/reap the object if still stale
196  */
197  void sweep(void);
198 
199  /**
200  * HW configuration for the result of creating the endpoint_group
201  */
202  HW::item<bool> m_hw;
203 
204  /**
205  * The EPG ID
206  */
207  vnid_t m_vnid;
208 
209  /**
210  * The SClass on the wire
211  */
212  uint16_t m_sclass;
213 
214  /**
215  * The uplink interface for the endpoint group
216  */
217  std::shared_ptr<interface> m_itf;
218 
219  /**
220  * The route-domain the EPG uses
221  */
222  std::shared_ptr<gbp_route_domain> m_rd;
223 
224  /**
225  * The bridge-domain the EPG uses
226  */
227  std::shared_ptr<gbp_bridge_domain> m_bd;
228 
229  /**
230  * The Group's EP retention Policy
231  */
232  retention_t m_retention;
233 
234  /**
235  * A map of all bridge_domains
236  */
238 };
239 
240 }; // namespace
241 
242 /*
243  * fd.io coding-style-patch-verification: ON
244  *
245  * Local Variables:
246  * eval: (c-set-style "mozilla")
247  * End:
248  */
249 
250 #endif
bool operator==(const retention_t &o) const
uint16_t sclass_t
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
Endpoint Retention Policy Settings.
const key_t key() const
Return the object&#39;s key.
uint32_t remote_ep_timeout
Remote Endpoint timeout/ageing.
sclass_t key_t
The key for a GBP endpoint group is its ID.
gbp_endpoint_group(vnid_t vnid, sclass_t sclass, const interface &itf, const gbp_route_domain &rd, const gbp_bridge_domain &bd)
Construct a GBP endpoint_group.
A entry in the ARP termination table of a Bridge Domain.
retention_t & operator=(const retention_t &)=default
std::shared_ptr< gbp_endpoint_group > singular() const
Return the matching &#39;singular instance&#39;.
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
A representation of an interface in VPP.
Definition: interface.hpp:41
A entry in the ARP termination table of a Bridge Domain.
Class definition for listeners to OM events.
Definition: om.hpp:284
inspect command handler Handler
Definition: inspect.hpp:54
const std::shared_ptr< gbp_bridge_domain > get_bridge_domain() const
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
static void dump(std::ostream &os)
Dump all bridge_domain-doamin into the stream provided.
A base class for all object_base in the VPP object_base-Model.
Definition: object_base.hpp:29
const std::shared_ptr< gbp_route_domain > get_route_domain() const
A entry in the ARP termination table of a Route Domain.
The VPP Object Model (VOM) library.
Definition: acl_binding.cpp:19
uint32_t vnid_t
EPG IDs are 32 bit integers.
void show(char *chroot_path, int verbose)
Definition: svmtool.c:105
static std::shared_ptr< gbp_endpoint_group > find(const key_t &k)
Find the instnace of the bridge_domain domain in the OM.
vnid_t vnid() const
Get the ID of the EPG.