OpenSDN source code
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, KSyncBulkMsgContextWaitTree
 
typedef std::pair< uint32_t, KSyncBulkMsgContextWaitTreePair
 
typedef boost::function< void(const boost::system::error_code &, size_t)> HandlerCb
 
typedef WorkQueue< KSyncRxDataKSyncReceiveQueue
 
typedef WorkQueue< KSyncRxQueueDataKSyncRxWorkQueue
 

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 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

◆ HandlerCb

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

Definition at line 326 of file ksync_sock.h.

◆ KSyncReceiveQueue

Definition at line 343 of file ksync_sock.h.

◆ KSyncRxWorkQueue

◆ WaitTree

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

Definition at line 323 of file ksync_sock.h.

◆ WaitTreePair

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

Definition at line 324 of file ksync_sock.h.

Constructor & Destructor Documentation

◆ KSyncSock()

KSyncSock::KSyncSock ( )

Definition at line 165 of file ksync_sock.cc.

Here is the call graph for this function:

◆ ~KSyncSock()

KSyncSock::~KSyncSock ( )
virtual

Definition at line 198 of file ksync_sock.cc.

Here is the call graph for this function:

Member Function Documentation

◆ AllocQueue()

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

Definition at line 232 of file ksync_sock.cc.

Here is the call graph for this function:

◆ AllocSeqNo() [1/2]

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

Definition at line 299 of file ksync_sock.cc.

◆ AllocSeqNo() [2/2]

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:

◆ AsyncReceive()

virtual void KSyncSock::AsyncReceive ( boost::asio::mutable_buffers_1  ,
HandlerCb   
)
privatepure virtual

◆ AsyncSendTo()

virtual void KSyncSock::AsyncSendTo ( KSyncBufferList iovec,
uint32_t  seq_no,
HandlerCb  cb 
)
privatepure virtual

◆ BlockingRecv()

bool KSyncSock::BlockingRecv ( )

Definition at line 419 of file ksync_sock.cc.

Here is the call graph for this function:

◆ BlockingSend()

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:

◆ BulkDecoder()

virtual bool KSyncSock::BulkDecoder ( char *  data,
KSyncBulkSandeshContext ctxt 
)
pure virtual

◆ Decoder()

virtual bool KSyncSock::Decoder ( char *  data,
AgentSandeshContext ctxt 
)
pure virtual

◆ DISALLOW_COPY_AND_ASSIGN()

KSyncSock::DISALLOW_COPY_AND_ASSIGN ( KSyncSock  )
private

◆ EnqueueRxProcessData()

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:

◆ GenericSend()

void KSyncSock::GenericSend ( IoContext ctx)

Definition at line 451 of file ksync_sock.cc.

Here is the call graph for this function:

◆ Get() [1/2]

KSyncSock * KSyncSock::Get ( DBTablePartBase partition)
static

Definition at line 340 of file ksync_sock.cc.

◆ Get() [2/2]

KSyncSock * KSyncSock::Get ( int  partition_id)
static

Definition at line 344 of file ksync_sock.cc.

◆ get_receive_work_queue()

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

Definition at line 402 of file ksync_sock.h.

◆ GetAgentSandeshContext()

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

Definition at line 394 of file ksync_sock.h.

◆ GetBulkSandeshContext()

KSyncBulkSandeshContext * KSyncSock::GetBulkSandeshContext ( uint32_t  seqno)
protected

Definition at line 331 of file ksync_sock.cc.

◆ GetNetlinkFamilyId()

static int KSyncSock::GetNetlinkFamilyId ( )
inlinestatic

Definition at line 391 of file ksync_sock.h.

◆ GetPid()

static uint32_t KSyncSock::GetPid ( )
inlinestatic

Definition at line 390 of file ksync_sock.h.

◆ GetReceiveQueue() [1/2]

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

Definition at line 303 of file ksync_sock.cc.

◆ GetReceiveQueue() [2/2]

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

Definition at line 312 of file ksync_sock.cc.

Here is the call graph for this function:

◆ GetSeqno()

virtual uint32_t KSyncSock::GetSeqno ( char *  data)
privatepure virtual

◆ Init()

void KSyncSock::Init ( bool  use_work_queue,
const std::string &  cpu_pin_policy 
)
staticprotected

Definition at line 226 of file ksync_sock.cc.

◆ IsMoreData()

virtual bool KSyncSock::IsMoreData ( char *  data)
privatepure virtual

◆ LocateBulkContext()

KSyncBulkMsgContext * KSyncSock::LocateBulkContext ( uint32_t  seqno,
IoContext::Type  io_context_type,
uint32_t  work_queue_index 
)

Definition at line 543 of file ksync_sock.cc.

Here is the call graph for this function:

◆ OnEmptyQueue()

void KSyncSock::OnEmptyQueue ( bool  done)

Definition at line 481 of file ksync_sock.cc.

Here is the call graph for this function:

◆ ProcessDataInline()

void KSyncSock::ProcessDataInline ( char *  data)
protected

Definition at line 834 of file ksync_sock.cc.

Here is the call graph for this function:

◆ ProcessKernelData()

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:

◆ ProcessRxData()

bool KSyncSock::ProcessRxData ( KSyncRxQueueData  data)
private

Definition at line 325 of file ksync_sock.cc.

Here is the call graph for this function:

◆ ReadHandler()

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:

◆ Receive()

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

◆ reset_use_wait_tree()

void KSyncSock::reset_use_wait_tree ( )
inline

Definition at line 414 of file ksync_sock.h.

◆ send_queue()

const KSyncTxQueue* KSyncSock::send_queue ( ) const
inline

Definition at line 401 of file ksync_sock.h.

◆ SendAsync()

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:

◆ SendAsyncImpl()

bool KSyncSock::SendAsyncImpl ( IoContext ioc)
private

Definition at line 622 of file ksync_sock.cc.

Here is the call graph for this function:

◆ SendAsyncStart()

bool KSyncSock::SendAsyncStart ( )
inlineprivate

Definition at line 475 of file ksync_sock.h.

◆ SendBulkMessage()

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:

◆ SendTo()

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

◆ set_process_data_inline()

void KSyncSock::set_process_data_inline ( )
inline

Definition at line 415 of file ksync_sock.h.

◆ SetAgentSandeshContext()

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

Definition at line 397 of file ksync_sock.h.

◆ SetMeasureQueueDelay()

void KSyncSock::SetMeasureQueueDelay ( bool  val)

Definition at line 245 of file ksync_sock.cc.

Here is the call graph for this function:

◆ SetNetlinkFamilyId()

void KSyncSock::SetNetlinkFamilyId ( int  id)
static

Definition at line 269 of file ksync_sock.cc.

Here is the call graph for this function:

◆ SetSeqno()

void KSyncSock::SetSeqno ( uint32_t  seq)

Definition at line 278 of file ksync_sock.cc.

◆ SetSockTableEntry()

void KSyncSock::SetSockTableEntry ( KSyncSock sock)
staticprotected

Definition at line 264 of file ksync_sock.cc.

◆ Shutdown()

void KSyncSock::Shutdown ( )
static

Definition at line 220 of file ksync_sock.cc.

◆ Start()

void KSyncSock::Start ( bool  read_inline)
static

Definition at line 252 of file ksync_sock.cc.

Here is the call graph for this function:

◆ TryAddToBulk()

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:

◆ tx_count()

int KSyncSock::tx_count ( ) const
inline

Definition at line 380 of file ksync_sock.h.

◆ Validate()

virtual bool KSyncSock::Validate ( char *  data)
privatepure virtual

◆ ValidateAndEnqueue()

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:

◆ WaitTreeSize()

uint32_t KSyncSock::WaitTreeSize ( ) const

Definition at line 274 of file ksync_sock.cc.

◆ WriteHandler()

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

◆ KSyncTxQueue

friend class KSyncTxQueue
friend

Definition at line 453 of file ksync_sock.h.

Member Data Documentation

◆ ack_count_

int KSyncSock::ack_count_
private

Definition at line 495 of file ksync_sock.h.

◆ agent_sandesh_ctx_

AgentSandeshContext * KSyncSock::agent_sandesh_ctx_
staticprivate

Definition at line 509 of file ksync_sock.h.

◆ bmca_cons_

uint32_t KSyncSock::bmca_cons_
protected

Definition at line 449 of file ksync_sock.h.

◆ bmca_prod_

uint32_t KSyncSock::bmca_prod_
protected

Definition at line 448 of file ksync_sock.h.

◆ bulk_buf_size_

uint32_t KSyncSock::bulk_buf_size_
protected

Definition at line 444 of file ksync_sock.h.

◆ bulk_mctx_arr_

KSyncBulkMsgContext* KSyncSock::bulk_mctx_arr_[KSYNC_BMC_ARR_SIZE]
protected

Definition at line 450 of file ksync_sock.h.

◆ bulk_msg_context_

KSyncBulkMsgContext* KSyncSock::bulk_msg_context_
private

Definition at line 487 of file ksync_sock.h.

◆ bulk_msg_count_

uint32_t KSyncSock::bulk_msg_count_
protected

Definition at line 446 of file ksync_sock.h.

◆ bulk_seq_no_

uint32_t KSyncSock::bulk_seq_no_
protected

Definition at line 442 of file ksync_sock.h.

◆ err_count_

int KSyncSock::err_count_
private

Definition at line 496 of file ksync_sock.h.

◆ kBufLen

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

Definition at line 316 of file ksync_sock.h.

◆ kInvalidBulkSeqNo

const unsigned KSyncSock::kInvalidBulkSeqNo = 0xFFFFFFFF
static

Definition at line 321 of file ksync_sock.h.

◆ kMaxBulkMsgCount

const unsigned KSyncSock::kMaxBulkMsgCount = 16
static

Definition at line 319 of file ksync_sock.h.

◆ kMsgGrowSize

const int KSyncSock::kMsgGrowSize = 16
static

Definition at line 315 of file ksync_sock.h.

◆ kRxWorkQueueCount

const int KSyncSock::kRxWorkQueueCount = 2
static

Definition at line 314 of file ksync_sock.h.

◆ ksync_bulk_sandesh_context_

KSyncBulkSandeshContext KSyncSock::ksync_bulk_sandesh_context_[kRxWorkQueueCount]
private

Definition at line 490 of file ksync_sock.h.

◆ ksync_rx_queue

KSyncReceiveQueue* KSyncSock::ksync_rx_queue[kRxWorkQueueCount]
protected

Definition at line 431 of file ksync_sock.h.

◆ max_bulk_buf_size_

uint32_t KSyncSock::max_bulk_buf_size_
protected

Definition at line 438 of file ksync_sock.h.

◆ max_bulk_msg_count_

uint32_t KSyncSock::max_bulk_msg_count_
protected

Definition at line 436 of file ksync_sock.h.

◆ mutex_

tbb::mutex KSyncSock::mutex_
protected

Definition at line 425 of file ksync_sock.h.

◆ nl_client_

nl_client* KSyncSock::nl_client_
protected

Definition at line 426 of file ksync_sock.h.

◆ pid_

pid_t KSyncSock::pid_
staticprivate

Definition at line 503 of file ksync_sock.h.

◆ process_data_inline_

bool KSyncSock::process_data_inline_
private

Definition at line 489 of file ksync_sock.h.

◆ read_inline_

bool KSyncSock::read_inline_
private

Definition at line 486 of file ksync_sock.h.

◆ rx_buff_

char* KSyncSock::rx_buff_
private

Definition at line 481 of file ksync_sock.h.

◆ rx_process_queue_

KSyncRxWorkQueue KSyncSock::rx_process_queue_
private

Definition at line 501 of file ksync_sock.h.

◆ send_queue_

KSyncTxQueue KSyncSock::send_queue_
protected

Definition at line 429 of file ksync_sock.h.

◆ seqno_

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

Definition at line 482 of file ksync_sock.h.

◆ shutdown_

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

Definition at line 510 of file ksync_sock.h.

◆ sock_

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

Definition at line 502 of file ksync_sock.h.

◆ tx_count_

int KSyncSock::tx_count_
private

Definition at line 494 of file ksync_sock.h.

◆ use_wait_tree_

bool KSyncSock::use_wait_tree_
private

Definition at line 488 of file ksync_sock.h.

◆ uve_bulk_sandesh_context_

KSyncBulkSandeshContext KSyncSock::uve_bulk_sandesh_context_[kRxWorkQueueCount]
private

Definition at line 491 of file ksync_sock.h.

◆ uve_rx_queue

KSyncReceiveQueue* KSyncSock::uve_rx_queue[kRxWorkQueueCount]
protected

Definition at line 430 of file ksync_sock.h.

◆ uve_seqno_

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

Definition at line 483 of file ksync_sock.h.

◆ vnsw_netlink_family_id_

int KSyncSock::vnsw_netlink_family_id_
staticprivate

Definition at line 504 of file ksync_sock.h.

◆ wait_tree_

WaitTree KSyncSock::wait_tree_
protected

Definition at line 428 of file ksync_sock.h.


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