53 std::shared_ptr<cmd> sp(c);
55 m_queue.push_back(sp);
68 std::shared_ptr<cmd> sp(cmds.front());
70 m_queue.push_back(sp);
83 m_rx_thread.reset(
new std::thread(&HW::cmd_q::rx_run,
this));
97 if (m_rx_thread && m_rx_thread->joinable()) {
125 auto it = m_queue.begin();
127 while (
it != m_queue.end()) {
128 std::shared_ptr<cmd>
c = *
it;
139 rc = c->issue(m_conn);
165 m_queue.erase(m_queue.begin(), m_queue.end());
207 m_cmdQ =
new cmd_q();
214 m_cmdQ->enqueue(cmd);
220 m_cmdQ->enqueue(cmd);
226 m_cmdQ->enqueue(cmds);
232 return (m_cmdQ->connect() && m_statReader->connect());
238 m_statReader->disconnect();
239 m_cmdQ->disconnect();
257 return (m_cmdQ->write());
268 return (m_poll_state);
274 m_statReader->read();
281 std::ostringstream os;
284 <<
"rc:" << item_rc.to_string() <<
" data:" << item_data <<
"]";
292 std::ostringstream os;
295 <<
"rc:" << item_rc.to_string() <<
" data:" << item_data <<
"]";
static void read_stats()
read stats from stat segment
static rc_t write()
Write/Execute all commands hitherto enqueued.
Error codes that VPP will return during a HW write.
static const log_level_t DEBUG
A command poll the HW for liveness.
virtual bool connect()
Blocking Connect to VPP - call once at bootup.
std::string to_string() const
convert to string format for debug purposes
pthread_t thread[MAX_CONNS]
static bool connect()
Blocking Connect to VPP.
virtual rc_t write()
Write all the commands to HW.
void enable()
Enable the passing of commands to VPP - undoes the disable.
The pipe to VPP into which we write the commands.
cmd_q & operator=(const cmd_q &f)
Copy assignement - only used in UT.
virtual void disconnect()
Disconnect to VPP.
vapi_error_e dispatch(const Common_req *limit=nullptr, u32 time=5)
wait for responses from vpp and assign them to appropriate objects
static void init()
Initialise the HW.
static const rc_t OK
The HW write was successfull.
static void enqueue(cmd *f)
Enqueue A command for execution.
static void disconnect()
Disconnect to VPP.
void disconnect()
Blocking disconnect.
static const log_level_t ERROR
vapi::Connection & ctx()
Retrun the VAPI context the commands will use.
The VPP Object Model (VOM) library.
Stat reader: single interface to get stats.
A representation of a method call to VPP.
void disable()
Disable the passing of commands to VPP.
int connect()
Blocking [re]connect call - always eventually succeeds, or the universe expires.
save_rewrite_length must be aligned so that reass doesn t overwrite it
virtual void enqueue(cmd *c)
Enqueue a command into the Q.
static bool poll()
Blocking pool of the HW connection.