OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
KSyncSock Class Referenceabstract

#include <ksync_sock.h>

Inheritance diagram for KSyncSock:
Collaboration diagram for KSyncSock:

Classes

struct  KSyncRxData
 
struct  KSyncRxQueueData
 

Public Types

typedef std::map< uint32_t,
KSyncBulkMsgContext
WaitTree
 
typedef std::pair< uint32_t,
KSyncBulkMsgContext
WaitTreePair
 
typedef boost::function< void(const
boost::system::error_code
&, size_t)> 
HandlerCb
 
typedef WorkQueue< KSyncRxDataKSyncReceiveQueue
 
typedef WorkQueue
< KSyncRxQueueData
KSyncRxWorkQueue
 

Public Member Functions

 KSyncSock ()
 
virtual ~KSyncSock ()
 
virtual bool BulkDecoder (char *data, KSyncBulkSandeshContext *ctxt)=0
 
virtual bool Decoder (char *data, AgentSandeshContext *ctxt)=0
 
void SendAsync (KSyncEntry *entry, int msg_len, char *msg, KSyncEntry::KSyncEvent event)
 
std::size_t BlockingSend (char *msg, int msg_len)
 
bool BlockingRecv ()
 
void GenericSend (IoContext *ctx)
 
uint32_t AllocSeqNo (IoContext::Type type)
 
uint32_t AllocSeqNo (IoContext::Type type, uint32_t instance)
 
KSyncReceiveQueueGetReceiveQueue (IoContext::Type type, uint32_t instance)
 
KSyncReceiveQueueGetReceiveQueue (uint32_t seqno)
 
KSyncBulkMsgContextLocateBulkContext (uint32_t seqno, IoContext::Type io_context_type, uint32_t work_queue_index)
 
int SendBulkMessage (KSyncBulkMsgContext *bulk_context, uint32_t seqno)
 
bool TryAddToBulk (KSyncBulkMsgContext *bulk_context, IoContext *ioc)
 
void OnEmptyQueue (bool done)
 
int tx_count () const
 
const KSyncTxQueuesend_queue () const
 
const KSyncReceiveQueueget_receive_work_queue (uint16_t index) const
 
KSyncReceiveQueueAllocQueue (KSyncBulkSandeshContext ctxt[], uint32_t task_id, uint32_t instance, const char *name)
 
uint32_t WaitTreeSize () const
 
void SetSeqno (uint32_t seq)
 
void SetMeasureQueueDelay (bool val)
 
void reset_use_wait_tree ()
 
void set_process_data_inline ()
 
void EnqueueRxProcessData (KSyncEntry *entry, KSyncEntry::KSyncEvent event)
 

Static Public Member Functions

static void Start (bool read_inline)
 
static void Shutdown ()
 
static KSyncSockGet (DBTablePartBase *partition)
 
static KSyncSockGet (int partition_id)
 
static uint32_t GetPid ()
 
static int GetNetlinkFamilyId ()
 
static void SetNetlinkFamilyId (int id)
 
static AgentSandeshContextGetAgentSandeshContext (uint32_t type)
 
static void SetAgentSandeshContext (AgentSandeshContext *ctx, uint32_t idx)
 

Static Public Attributes

static const int kRxWorkQueueCount = 2
 
static const int kMsgGrowSize = 16
 
static const unsigned kBufLen = (4*1024)
 
static const unsigned kMaxBulkMsgCount = 16
 
static const unsigned kMaxBulkMsgSize = (4*1024)
 
static const unsigned kInvalidBulkSeqNo = 0xFFFFFFFF
 

Protected Member Functions

bool ValidateAndEnqueue (char *data, KSyncBulkMsgContext *context)
 
KSyncBulkSandeshContextGetBulkSandeshContext (uint32_t seqno)
 
void ProcessDataInline (char *data)
 

Static Protected Member Functions

static void Init (bool use_work_queue, const std::string &cpu_pin_policy)
 
static void SetSockTableEntry (KSyncSock *sock)
 

Protected Attributes

tbb::mutex mutex_
 
nl_client * nl_client_
 
WaitTree wait_tree_
 
KSyncTxQueue send_queue_
 
KSyncReceiveQueueuve_rx_queue [kRxWorkQueueCount]
 
KSyncReceiveQueueksync_rx_queue [kRxWorkQueueCount]
 
uint32_t max_bulk_msg_count_
 
uint32_t max_bulk_buf_size_
 
uint32_t bulk_seq_no_
 
uint32_t bulk_buf_size_
 
uint32_t bulk_msg_count_
 
uint32_t bmca_prod_
 
uint32_t bmca_cons_
 
KSyncBulkMsgContextbulk_mctx_arr_ [KSYNC_BMC_ARR_SIZE]
 

Private Member Functions

virtual void AsyncReceive (boost::asio::mutable_buffers_1, HandlerCb)=0
 
virtual void AsyncSendTo (KSyncBufferList *iovec, uint32_t seq_no, HandlerCb cb)=0
 
virtual std::size_t SendTo (KSyncBufferList *iovec, uint32_t seq_no)=0
 
virtual void Receive (boost::asio::mutable_buffers_1)=0
 
virtual uint32_t GetSeqno (char *data)=0
 
virtual bool IsMoreData (char *data)=0
 
virtual bool Validate (char *data)=0
 
void ReadHandler (const boost::system::error_code &error, size_t bytes_transferred)
 
void WriteHandler (const boost::system::error_code &error, size_t bytes_transferred)
 
bool ProcessKernelData (KSyncBulkSandeshContext *ksync_context, const KSyncRxData &data)
 
bool ProcessRxData (KSyncRxQueueData data)
 
bool SendAsyncImpl (IoContext *ioc)
 
bool SendAsyncStart ()
 
 DISALLOW_COPY_AND_ASSIGN (KSyncSock)
 

Private Attributes

char * rx_buff_
 
tbb::atomic< uint32_t > seqno_
 
tbb::atomic< uint32_t > uve_seqno_
 
bool read_inline_
 
KSyncBulkMsgContextbulk_msg_context_
 
bool use_wait_tree_
 
bool process_data_inline_
 
KSyncBulkSandeshContext ksync_bulk_sandesh_context_ [kRxWorkQueueCount]
 
KSyncBulkSandeshContext uve_bulk_sandesh_context_ [kRxWorkQueueCount]
 
int tx_count_
 
int ack_count_
 
int err_count_
 
KSyncRxWorkQueue rx_process_queue_
 

Static Private Attributes

static std::unique_ptr< KSyncSocksock_
 
static pid_t pid_
 
static int vnsw_netlink_family_id_
 
static AgentSandeshContextagent_sandesh_ctx_ [kRxWorkQueueCount]
 
static tbb::atomic< bool > shutdown_
 

Friends

class KSyncTxQueue
 

Detailed Description

Definition at line 311 of file ksync_sock.h.

Member Typedef Documentation

typedef boost::function<void(const boost::system::error_code &, size_t)> KSyncSock::HandlerCb

Definition at line 328 of file ksync_sock.h.

Definition at line 345 of file ksync_sock.h.

typedef std::map<uint32_t, KSyncBulkMsgContext> KSyncSock::WaitTree

Definition at line 325 of file ksync_sock.h.

typedef std::pair<uint32_t, KSyncBulkMsgContext> KSyncSock::WaitTreePair

Definition at line 326 of file ksync_sock.h.

Constructor & Destructor Documentation

KSyncSock::KSyncSock ( )

Definition at line 165 of file ksync_sock.cc.

Here is the call graph for this function:

KSyncSock::~KSyncSock ( )
virtual

Definition at line 198 of file ksync_sock.cc.

Here is the call graph for this function:

Member Function Documentation

KSyncSock::KSyncReceiveQueue * KSyncSock::AllocQueue ( KSyncBulkSandeshContext  ctxt[],
uint32_t  task_id,
uint32_t  instance,
const char *  name 
)

Definition at line 233 of file ksync_sock.cc.

Here is the call graph for this function:

uint32_t KSyncSock::AllocSeqNo ( IoContext::Type  type)

Definition at line 299 of file ksync_sock.cc.

uint32_t KSyncSock::AllocSeqNo ( IoContext::Type  type,
uint32_t  instance 
)

Definition at line 283 of file ksync_sock.cc.

Here is the call graph for this function:

virtual void KSyncSock::AsyncReceive ( boost::asio::mutable_buffers_1  ,
HandlerCb   
)
privatepure virtual
virtual void KSyncSock::AsyncSendTo ( KSyncBufferList iovec,
uint32_t  seq_no,
HandlerCb  cb 
)
privatepure virtual
bool KSyncSock::BlockingRecv ( )

Definition at line 419 of file ksync_sock.cc.

Here is the call graph for this function:

size_t KSyncSock::BlockingSend ( char *  msg,
int  msg_len 
)

Definition at line 444 of file ksync_sock.cc.

Here is the call graph for this function:

virtual bool KSyncSock::BulkDecoder ( char *  data,
KSyncBulkSandeshContext ctxt 
)
pure virtual
virtual bool KSyncSock::Decoder ( char *  data,
AgentSandeshContext ctxt 
)
pure virtual
KSyncSock::DISALLOW_COPY_AND_ASSIGN ( KSyncSock  )
private
void KSyncSock::EnqueueRxProcessData ( KSyncEntry entry,
KSyncEntry::KSyncEvent  event 
)

Definition at line 322 of file ksync_sock.cc.

Here is the call graph for this function:

void KSyncSock::GenericSend ( IoContext ctx)

Definition at line 451 of file ksync_sock.cc.

Here is the call graph for this function:

KSyncSock * KSyncSock::Get ( DBTablePartBase partition)
static

Definition at line 340 of file ksync_sock.cc.

KSyncSock * KSyncSock::Get ( int  partition_id)
static

Definition at line 344 of file ksync_sock.cc.

const KSyncReceiveQueue* KSyncSock::get_receive_work_queue ( uint16_t  index) const
inline

Definition at line 404 of file ksync_sock.h.

static AgentSandeshContext* KSyncSock::GetAgentSandeshContext ( uint32_t  type)
inlinestatic

Definition at line 396 of file ksync_sock.h.

KSyncBulkSandeshContext * KSyncSock::GetBulkSandeshContext ( uint32_t  seqno)
protected

Definition at line 331 of file ksync_sock.cc.

static int KSyncSock::GetNetlinkFamilyId ( )
inlinestatic

Definition at line 393 of file ksync_sock.h.

static uint32_t KSyncSock::GetPid ( )
inlinestatic

Definition at line 392 of file ksync_sock.h.

KSyncSock::KSyncReceiveQueue * KSyncSock::GetReceiveQueue ( IoContext::Type  type,
uint32_t  instance 
)

Definition at line 303 of file ksync_sock.cc.

KSyncSock::KSyncReceiveQueue * KSyncSock::GetReceiveQueue ( uint32_t  seqno)

Definition at line 312 of file ksync_sock.cc.

Here is the call graph for this function:

virtual uint32_t KSyncSock::GetSeqno ( char *  data)
privatepure virtual
void KSyncSock::Init ( bool  use_work_queue,
const std::string &  cpu_pin_policy 
)
staticprotected

Definition at line 226 of file ksync_sock.cc.

virtual bool KSyncSock::IsMoreData ( char *  data)
privatepure virtual
KSyncBulkMsgContext * KSyncSock::LocateBulkContext ( uint32_t  seqno,
IoContext::Type  io_context_type,
uint32_t  work_queue_index 
)

Definition at line 544 of file ksync_sock.cc.

void KSyncSock::OnEmptyQueue ( bool  done)

Definition at line 481 of file ksync_sock.cc.

Here is the call graph for this function:

void KSyncSock::ProcessDataInline ( char *  data)
protected

Definition at line 837 of file ksync_sock.cc.

Here is the call graph for this function:

bool KSyncSock::ProcessKernelData ( KSyncBulkSandeshContext ksync_context,
const KSyncRxData data 
)
private

Definition at line 386 of file ksync_sock.cc.

Here is the call graph for this function:

bool KSyncSock::ProcessRxData ( KSyncRxQueueData  data)
private

Definition at line 325 of file ksync_sock.cc.

Here is the call graph for this function:

void KSyncSock::ReadHandler ( const boost::system::error_code &  error,
size_t  bytes_transferred 
)
private

Definition at line 364 of file ksync_sock.cc.

Here is the call graph for this function:

virtual void KSyncSock::Receive ( boost::asio::mutable_buffers_1  )
privatepure virtual
void KSyncSock::reset_use_wait_tree ( )
inline

Definition at line 416 of file ksync_sock.h.

const KSyncTxQueue* KSyncSock::send_queue ( ) const
inline

Definition at line 403 of file ksync_sock.h.

void KSyncSock::SendAsync ( KSyncEntry entry,
int  msg_len,
char *  msg,
KSyncEntry::KSyncEvent  event 
)

Definition at line 455 of file ksync_sock.cc.

Here is the call graph for this function:

bool KSyncSock::SendAsyncImpl ( IoContext ioc)
private

Definition at line 625 of file ksync_sock.cc.

Here is the call graph for this function:

bool KSyncSock::SendAsyncStart ( )
inlineprivate

Definition at line 477 of file ksync_sock.h.

int KSyncSock::SendBulkMessage ( KSyncBulkMsgContext bulk_context,
uint32_t  seqno 
)

Definition at line 503 of file ksync_sock.cc.

Here is the call graph for this function:

virtual std::size_t KSyncSock::SendTo ( KSyncBufferList iovec,
uint32_t  seq_no 
)
privatepure virtual
void KSyncSock::set_process_data_inline ( )
inline

Definition at line 417 of file ksync_sock.h.

static void KSyncSock::SetAgentSandeshContext ( AgentSandeshContext ctx,
uint32_t  idx 
)
inlinestatic

Definition at line 399 of file ksync_sock.h.

void KSyncSock::SetMeasureQueueDelay ( bool  val)

Definition at line 245 of file ksync_sock.cc.

Here is the call graph for this function:

void KSyncSock::SetNetlinkFamilyId ( int  id)
static

Definition at line 269 of file ksync_sock.cc.

Here is the call graph for this function:

void KSyncSock::SetSeqno ( uint32_t  seq)

Definition at line 278 of file ksync_sock.cc.

void KSyncSock::SetSockTableEntry ( KSyncSock sock)
staticprotected

Definition at line 264 of file ksync_sock.cc.

void KSyncSock::Shutdown ( )
static

Definition at line 220 of file ksync_sock.cc.

void KSyncSock::Start ( bool  read_inline)
static

Definition at line 252 of file ksync_sock.cc.

Here is the call graph for this function:

bool KSyncSock::TryAddToBulk ( KSyncBulkMsgContext bulk_context,
IoContext ioc 
)

Definition at line 593 of file ksync_sock.cc.

Here is the call graph for this function:

int KSyncSock::tx_count ( ) const
inline

Definition at line 382 of file ksync_sock.h.

virtual bool KSyncSock::Validate ( char *  data)
privatepure virtual
bool KSyncSock::ValidateAndEnqueue ( char *  data,
KSyncBulkMsgContext context 
)
protected

Definition at line 349 of file ksync_sock.cc.

Here is the call graph for this function:

uint32_t KSyncSock::WaitTreeSize ( ) const

Definition at line 274 of file ksync_sock.cc.

void KSyncSock::WriteHandler ( const boost::system::error_code &  error,
size_t  bytes_transferred 
)
private

Definition at line 469 of file ksync_sock.cc.

Friends And Related Function Documentation

friend class KSyncTxQueue
friend

Definition at line 455 of file ksync_sock.h.

Member Data Documentation

int KSyncSock::ack_count_
private

Definition at line 497 of file ksync_sock.h.

AgentSandeshContext * KSyncSock::agent_sandesh_ctx_
staticprivate

Definition at line 511 of file ksync_sock.h.

uint32_t KSyncSock::bmca_cons_
protected

Definition at line 451 of file ksync_sock.h.

uint32_t KSyncSock::bmca_prod_
protected

Definition at line 450 of file ksync_sock.h.

uint32_t KSyncSock::bulk_buf_size_
protected

Definition at line 446 of file ksync_sock.h.

KSyncBulkMsgContext* KSyncSock::bulk_mctx_arr_[KSYNC_BMC_ARR_SIZE]
protected

Definition at line 452 of file ksync_sock.h.

KSyncBulkMsgContext* KSyncSock::bulk_msg_context_
private

Definition at line 489 of file ksync_sock.h.

uint32_t KSyncSock::bulk_msg_count_
protected

Definition at line 448 of file ksync_sock.h.

uint32_t KSyncSock::bulk_seq_no_
protected

Definition at line 444 of file ksync_sock.h.

int KSyncSock::err_count_
private

Definition at line 498 of file ksync_sock.h.

const unsigned KSyncSock::kBufLen = (4*1024)
static

Definition at line 316 of file ksync_sock.h.

const unsigned KSyncSock::kInvalidBulkSeqNo = 0xFFFFFFFF
static

Definition at line 323 of file ksync_sock.h.

const unsigned KSyncSock::kMaxBulkMsgCount = 16
static

Definition at line 319 of file ksync_sock.h.

const unsigned KSyncSock::kMaxBulkMsgSize = (4*1024)
static

Definition at line 321 of file ksync_sock.h.

const int KSyncSock::kMsgGrowSize = 16
static

Definition at line 315 of file ksync_sock.h.

const int KSyncSock::kRxWorkQueueCount = 2
static

Definition at line 314 of file ksync_sock.h.

KSyncBulkSandeshContext KSyncSock::ksync_bulk_sandesh_context_[kRxWorkQueueCount]
private

Definition at line 492 of file ksync_sock.h.

KSyncReceiveQueue* KSyncSock::ksync_rx_queue[kRxWorkQueueCount]
protected

Definition at line 433 of file ksync_sock.h.

uint32_t KSyncSock::max_bulk_buf_size_
protected

Definition at line 440 of file ksync_sock.h.

uint32_t KSyncSock::max_bulk_msg_count_
protected

Definition at line 438 of file ksync_sock.h.

tbb::mutex KSyncSock::mutex_
protected

Definition at line 427 of file ksync_sock.h.

nl_client* KSyncSock::nl_client_
protected

Definition at line 428 of file ksync_sock.h.

pid_t KSyncSock::pid_
staticprivate

Definition at line 505 of file ksync_sock.h.

bool KSyncSock::process_data_inline_
private

Definition at line 491 of file ksync_sock.h.

bool KSyncSock::read_inline_
private

Definition at line 488 of file ksync_sock.h.

char* KSyncSock::rx_buff_
private

Definition at line 483 of file ksync_sock.h.

KSyncRxWorkQueue KSyncSock::rx_process_queue_
private

Definition at line 503 of file ksync_sock.h.

KSyncTxQueue KSyncSock::send_queue_
protected

Definition at line 431 of file ksync_sock.h.

tbb::atomic<uint32_t> KSyncSock::seqno_
private

Definition at line 484 of file ksync_sock.h.

tbb::atomic< bool > KSyncSock::shutdown_
staticprivate

Definition at line 512 of file ksync_sock.h.

std::unique_ptr< KSyncSock > KSyncSock::sock_
staticprivate

Definition at line 504 of file ksync_sock.h.

int KSyncSock::tx_count_
private

Definition at line 496 of file ksync_sock.h.

bool KSyncSock::use_wait_tree_
private

Definition at line 490 of file ksync_sock.h.

KSyncBulkSandeshContext KSyncSock::uve_bulk_sandesh_context_[kRxWorkQueueCount]
private

Definition at line 493 of file ksync_sock.h.

KSyncReceiveQueue* KSyncSock::uve_rx_queue[kRxWorkQueueCount]
protected

Definition at line 432 of file ksync_sock.h.

tbb::atomic<uint32_t> KSyncSock::uve_seqno_
private

Definition at line 485 of file ksync_sock.h.

int KSyncSock::vnsw_netlink_family_id_
staticprivate

Definition at line 506 of file ksync_sock.h.

WaitTree KSyncSock::wait_tree_
protected

Definition at line 430 of file ksync_sock.h.


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