27 #define N_ENDS (WEST + 1) 31 static const std::string
34 return (
"pipe" + std::to_string(instance));
42 , m_instance(instance)
54 , m_instance(o.m_instance)
65 << m_hdl_pair.
data().first <<
", " << m_hdl_pair.
data().second <<
"]]";
71 pipe::mk_create_cmd(std::queue<cmd*>& q)
79 pipe::mk_delete_cmd(std::queue<cmd*>& q)
89 return std::dynamic_pointer_cast<
pipe>(singular_i());
92 std::shared_ptr<interface>
93 pipe::singular_i()
const 95 return m_db.find_or_add(
key(), *
this);
101 return std::dynamic_pointer_cast<
pipe>(
m_db.find(k));
104 std::shared_ptr<interface>
109 m_ends[
WEST] = pipe_end(*
this, WEST).singular();
110 m_ends[
WEST]->set(m_hdl_pair.
data().first);
114 return (m_ends[WEST]);
117 std::shared_ptr<interface>
122 m_ends[
EAST] = pipe_end(*
this, EAST).singular();
123 m_ends[
EAST]->set(m_hdl_pair.
data().first);
127 return (m_ends[EAST]);
130 pipe::pipe_end::pipe_end(
const pipe& p, uint8_t
id)
139 pipe::pipe_end::mk_create_cmd(std::queue<cmd*>& q)
145 pipe::pipe_end::mk_delete_cmd(std::queue<cmd*>& q)
167 pipe::event_handler::handle_replay()
175 std::shared_ptr<pipe_cmds::dump_cmd>
cmd =
176 std::make_shared<pipe_cmds::dump_cmd>();
181 for (
auto& record : *cmd) {
182 std::shared_ptr<pipe> sp;
192 pipe::event_handler::order()
const
void release()
release/remove an interface form the singular store
A cmd class that Delete an interface.
interface(const std::string &name, type_t type, admin_state_t state, const std::string &tag="")
Construct a new object matching the desried state.
void db_dump(const DB &db, std::ostream &os)
Print each of the objects in the DB into the stream provided.
const std::string key_t
In the opflex world each entity is known by a URI which can be converted into a string.
pipe(uint32_t instance, admin_state_t state)
Construct a new object matching the desried state.
virtual interfaces - those that depend on some real interface
HW::item< handle_t > m_hdl
The SW interface handle VPP has asigned to the interface.
virtual std::string to_string(void) const
convert to string format for debug purposes
static std::shared_ptr< pipe > new_pipe_interface(const vapi_payload_pipe_details &payload)
virtual void sweep(void)
Sweep/reap the object if still stale.
static void register_handler(const std::vector< std::string > &cmds, const std::string &help, command_handler *ch)
Register a command handler for inspection.
static rc_t write()
Write/Execute all commands hitherto enqueued.
static const log_level_t DEBUG
static const handle_t INVALID
A value of an interface handle_t that means the itf does not exist.
T & data()
Return the data read/written.
static singular_db< key_t, interface > m_db
A map of all interfaces key against the interface's name.
A functor class that creates an interface.
vhost_vring_state_t state
rc_t rc() const
Get the HW return code.
std::shared_ptr< interface > east()
The interface that is the east end of the pipe.
std::shared_ptr< pipe > singular() const
Return the matching 'singular instance' of the sub-interface.
static const type_t PIPE_END
pipe-end type
The admin state of the interface.
A representation of an interface in VPP.
static rc_t commit(const client_db::key_t &key, const OBJ &obj)
Make the State in VPP reflect the expressed desired state.
void event_handler(void *tls_async)
dependency_t
There needs to be a strict order in which object types are read from VPP (at boot time) and replayed ...
static const rc_t OK
The HW write was successfull.
const std::string & name() const
Return the interface type.
static void enqueue(cmd *f)
Enqueue A command for execution.
std::pair< handle_t, handle_t > handle_pair_t
static const rc_t INVALID
HW write reported invalid input.
The VPP Object Model (VOM) library.
static const admin_state_t UP
Admin UP state.
A representation of a method call to VPP.
std::shared_ptr< interface > west()
The interface that is the west end of the pipe.
static const std::string pipe_mk_name(uint32_t instance)
void set_ends(const handle_pair_t &p)
const std::string & to_string() const
convert to string format for debug purposes
static std::shared_ptr< pipe > find(const key_t &k)
Find a subinterface from its key.
virtual std::string to_string(void) const
convert to string format for debug purposes
std::string key_t
The key for interface's key.
static bool register_listener(listener *listener)
Register a listener of events.
const key_t & key() const
Return the interface type.