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:
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_GBP_ENDPOINT_GROUP_H__
17 #define __VOM_GBP_ENDPOINT_GROUP_H__
19 #include "vom/interface.hpp"
20 #include "vom/singular_db.hpp"
21 #include "vom/types.hpp"
23 #include "vom/gbp_bridge_domain.hpp"
24 #include "vom/gbp_route_domain.hpp"
29 * EPG IDs are 32 bit integers
31 typedef uint32_t vnid_t;
32 typedef uint16_t sclass_t;
35 * A entry in the ARP termination table of a Bridge Domain
37 class gbp_endpoint_group : public object_base
41 * Endpoint Retention Policy Settings
46 retention_t(uint32_t remote_ep_timeout);
48 retention_t(const retention_t&) = default;
49 retention_t& operator=(const retention_t&) = default;
51 bool operator==(const retention_t& o) const;
52 std::string to_string() const;
55 * Remote Endpoint timeout/ageing
57 uint32_t remote_ep_timeout;
61 * The key for a GBP endpoint group is its ID
63 typedef sclass_t key_t;
66 * Construct a GBP endpoint_group
68 gbp_endpoint_group(vnid_t vnid,
71 const gbp_route_domain& rd,
72 const gbp_bridge_domain& bd);
73 gbp_endpoint_group(vnid_t vnid,
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);
84 gbp_endpoint_group(const gbp_endpoint_group& r);
89 ~gbp_endpoint_group();
92 * Return the object's key
94 const key_t key() const;
99 bool operator==(const gbp_endpoint_group& bdae) const;
102 * Return the matching 'singular instance'
104 std::shared_ptr<gbp_endpoint_group> singular() const;
107 * Find the instnace of the bridge_domain domain in the OM
109 static std::shared_ptr<gbp_endpoint_group> find(const key_t& k);
112 * Dump all bridge_domain-doamin into the stream provided
114 static void dump(std::ostream& os);
117 * replay the object to create it in hardware
122 * Convert to string for debugging
124 std::string to_string() const;
127 * Get the ID of the EPG
130 sclass_t sclass() const;
132 const std::shared_ptr<gbp_route_domain> get_route_domain() const;
133 const std::shared_ptr<gbp_bridge_domain> get_bridge_domain() const;
135 void set(const retention_t& retention);
139 * Class definition for listeners to OM events
141 class event_handler : public OM::listener, public inspect::command_handler
145 virtual ~event_handler() = default;
148 * Handle a populate event
150 void handle_populate(const client_db::key_t& key);
153 * Handle a replay event
155 void handle_replay();
158 * Show the object in the Singular DB
160 void show(std::ostream& os);
163 * Get the sortable Id of the listener
165 dependency_t order() const;
169 * event_handler to register with OM
171 static event_handler m_evh;
174 * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
176 void update(const gbp_endpoint_group& obj);
179 * Find or add the instnace of the bridge_domain domain in the OM
181 static std::shared_ptr<gbp_endpoint_group> find_or_add(
182 const gbp_endpoint_group& temp);
185 * It's the VPPHW class that updates the objects in HW
190 * It's the singular_db class that calls replay()
192 friend class singular_db<key_t, gbp_endpoint_group>;
195 * Sweep/reap the object if still stale
200 * HW configuration for the result of creating the endpoint_group
210 * The SClass on the wire
215 * The uplink interface for the endpoint group
217 std::shared_ptr<interface> m_itf;
220 * The route-domain the EPG uses
222 std::shared_ptr<gbp_route_domain> m_rd;
225 * The bridge-domain the EPG uses
227 std::shared_ptr<gbp_bridge_domain> m_bd;
230 * The Group's EP retention Policy
232 retention_t m_retention;
235 * A map of all bridge_domains
237 static singular_db<key_t, gbp_endpoint_group> m_db;
243 * fd.io coding-style-patch-verification: ON
246 * eval: (c-set-style "mozilla")