FD.io VPP  v20.05.1-6-gf53edbc3b
Vector Packet Processing
VOM::rpc_cmd< HWITEM, MSG > Class Template Reference

A base class for all RPC commands to VPP. More...

+ Inheritance diagram for VOM::rpc_cmd< HWITEM, MSG >:
+ Collaboration diagram for VOM::rpc_cmd< HWITEM, MSG >:

Public Types

typedef MSG msg_t
 convenient typedef More...
 

Public Member Functions

 rpc_cmd (HWITEM &item)
 Constructor taking the HW item that will be updated by the command. More...
 
virtual ~rpc_cmd ()
 Desructor. More...
 
HWITEM & item ()
 return the HW item the command updates More...
 
const HWITEM & item () const
 return the const HW item the command updates More...
 
void fulfill (const HWITEM &d)
 Fulfill the commands promise. More...
 
rc_t wait ()
 Wait on the commands promise. More...
 
virtual void succeeded ()
 Called by the HW Command Q when it is disabled to indicate the command can be considered successful without issuing it to HW. More...
 
virtual vapi_error_e operator() (MSG &reply)
 call operator used as a callback by VAPI when the reply is available More...
 
virtual void retire (connection &con)
 Retire/cancel a long running command. More...
 
- Public Member Functions inherited from VOM::cmd
 cmd ()
 Default constructor. More...
 
virtual ~cmd ()
 Virtual destructor. More...
 
virtual rc_t issue (connection &con)=0
 Issue the command to VPP/HW. More...
 
virtual std::string to_string () const =0
 convert to string format for debug purposes More...
 

Protected Attributes

HWITEM & m_hw_item
 A reference to an object's HW::item that the command will update. More...
 
std::promise< HWITEM > m_promise
 The promise that implements the synchronous issue. More...
 

Detailed Description

template<typename HWITEM, typename MSG>
class VOM::rpc_cmd< HWITEM, MSG >

A base class for all RPC commands to VPP.

RPC commands are one of the sub-set of command types to VPP that modify/create state in VPP and thus return an error code. Commands are issued in one thread context, but read in another. The command has an associated std::promise that is met by the RX thread. this allows the sender, which waits on the promise's future, to experience a synchronous command.

The command is templatised on the type of the HW::item to be set by the command, and the data returned in the promise,

Definition at line 40 of file rpc_cmd.hpp.

Member Typedef Documentation

◆ msg_t

template<typename HWITEM, typename MSG>
typedef MSG VOM::rpc_cmd< HWITEM, MSG >::msg_t

convenient typedef

Definition at line 46 of file rpc_cmd.hpp.

Constructor & Destructor Documentation

◆ rpc_cmd()

template<typename HWITEM, typename MSG>
VOM::rpc_cmd< HWITEM, MSG >::rpc_cmd ( HWITEM &  item)
inline

Constructor taking the HW item that will be updated by the command.

Definition at line 51 of file rpc_cmd.hpp.

◆ ~rpc_cmd()

template<typename HWITEM, typename MSG>
virtual VOM::rpc_cmd< HWITEM, MSG >::~rpc_cmd ( )
inlinevirtual

Desructor.

Definition at line 61 of file rpc_cmd.hpp.

Member Function Documentation

◆ fulfill()

template<typename HWITEM, typename MSG>
void VOM::rpc_cmd< HWITEM, MSG >::fulfill ( const HWITEM &  d)
inline

Fulfill the commands promise.

Called from the RX thread

Definition at line 76 of file rpc_cmd.hpp.

+ Here is the caller graph for this function:

◆ item() [1/2]

template<typename HWITEM, typename MSG>
HWITEM& VOM::rpc_cmd< HWITEM, MSG >::item ( )
inline

return the HW item the command updates

Definition at line 66 of file rpc_cmd.hpp.

+ Here is the caller graph for this function:

◆ item() [2/2]

template<typename HWITEM, typename MSG>
const HWITEM& VOM::rpc_cmd< HWITEM, MSG >::item ( ) const
inline

return the const HW item the command updates

Definition at line 71 of file rpc_cmd.hpp.

◆ operator()()

◆ retire()

template<typename HWITEM, typename MSG>
virtual void VOM::rpc_cmd< HWITEM, MSG >::retire ( connection con)
inlinevirtual

◆ succeeded()

template<typename HWITEM, typename MSG>
virtual void VOM::rpc_cmd< HWITEM, MSG >::succeeded ( )
inlinevirtual

Called by the HW Command Q when it is disabled to indicate the command can be considered successful without issuing it to HW.

Implements VOM::cmd.

Reimplemented in VOM::interface::delete_cmd< MSG >, VOM::interface::delete_cmd< vapi::Vxlan_gbp_tunnel_add_del >, VOM::interface::delete_cmd< vapi::Bvi_delete >, VOM::interface::delete_cmd< vapi::Af_packet_delete >, VOM::interface::delete_cmd< vapi::Bond_delete >, VOM::interface::delete_cmd< vapi::Pipe_delete >, VOM::interface::delete_cmd< vapi::Vxlan_add_del_tunnel >, VOM::interface::delete_cmd< vapi::Delete_subif >, VOM::interface::delete_cmd< vapi::Gbp_vxlan_tunnel_del >, VOM::interface::delete_cmd< vapi::Delete_vhost_user_if >, VOM::interface::delete_cmd< vapi::Tap_delete_v2 >, VOM::interface::delete_cmd< vapi::Delete_loopback >, VOM::interface::create_cmd< MSG >, VOM::interface::create_cmd< vapi::Vxlan_gbp_tunnel_add_del >, VOM::interface::create_cmd< vapi::Create_vhost_user_if >, VOM::interface::create_cmd< vapi::Af_packet_create >, VOM::interface::create_cmd< vapi::Bond_create >, VOM::interface::create_cmd< vapi::Vxlan_add_del_tunnel >, VOM::interface::create_cmd< vapi::Pipe_create >, VOM::interface::create_cmd< vapi::Gbp_vxlan_tunnel_add >, VOM::interface::create_cmd< vapi::Create_loopback >, VOM::interface::create_cmd< vapi::Bvi_create >, VOM::interface::create_cmd< vapi::Create_vlan_subif >, VOM::interface::create_cmd< vapi::Tap_create_v2 >, and VOM::ACL::list_cmds::update_cmd< LIST, UPDATE >.

Definition at line 103 of file rpc_cmd.hpp.

◆ wait()

template<typename HWITEM, typename MSG>
rc_t VOM::rpc_cmd< HWITEM, MSG >::wait ( )
inline

Wait on the commands promise.

i.e. block on the completion of the command.

Definition at line 82 of file rpc_cmd.hpp.

Field Documentation

◆ m_hw_item

template<typename HWITEM, typename MSG>
HWITEM& VOM::rpc_cmd< HWITEM, MSG >::m_hw_item
protected

A reference to an object's HW::item that the command will update.

Definition at line 134 of file rpc_cmd.hpp.

◆ m_promise

template<typename HWITEM, typename MSG>
std::promise<HWITEM> VOM::rpc_cmd< HWITEM, MSG >::m_promise
protected

The promise that implements the synchronous issue.

Definition at line 139 of file rpc_cmd.hpp.


The documentation for this class was generated from the following file: