Skip to content

Commit

Permalink
Merge "Use of token-less queues"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jun 23, 2016
2 parents 92fb820 + 43b2179 commit a5b8e09
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 35 deletions.
12 changes: 6 additions & 6 deletions src/vnsw/agent/oper/agent_profile.cc
Expand Up @@ -154,8 +154,8 @@ void ProfileData::FlowStats::Reset() {
for (uint16_t i = 0; i < flow_event_queue_.size(); i++) {
flow_event_queue_[i].Reset();
}
for (uint16_t i = 0; i < flow_misc_event_queue_.size(); i++) {
flow_misc_event_queue_[i].Reset();
for (uint16_t i = 0; i < flow_tokenless_queue_.size(); i++) {
flow_tokenless_queue_[i].Reset();
}
for (uint16_t i = 0; i < flow_delete_queue_.size(); i++) {
flow_delete_queue_[i].Reset();
Expand Down Expand Up @@ -483,15 +483,15 @@ static void GetQueueSummaryInfo(SandeshFlowQueueSummaryInfo *info, int index,
one.set_busy_msec(busy_time);
info->set_flow_event_queue(one);

// flow_misc_event_queue
// flow_tokenless_queue
qcount = 0;
enqueues = 0;
dequeues = 0;
max_qlen = 0;
busy_time = 0;
starts = 0;
it = flow_stats->flow_misc_event_queue_.begin();
while (it != flow_stats->flow_misc_event_queue_.end()) {
it = flow_stats->flow_tokenless_queue_.begin();
while (it != flow_stats->flow_tokenless_queue_.end()) {
qcount += it->queue_count_;
enqueues += it->enqueue_count_;
dequeues += it->dequeue_count_;
Expand All @@ -508,7 +508,7 @@ static void GetQueueSummaryInfo(SandeshFlowQueueSummaryInfo *info, int index,
one.set_max_qlen(max_qlen);
one.set_starts(starts);
one.set_busy_msec(busy_time);
info->set_flow_misc_event_queue(one);
info->set_flow_tokenless_queue(one);

// flow_delete_queue
qcount = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/oper/agent_profile.h
Expand Up @@ -65,7 +65,7 @@ class ProfileData {
WorkQueueStats flow_mgmt_queue_;
WorkQueueStats flow_update_queue_;
std::vector<WorkQueueStats> flow_event_queue_;
std::vector<WorkQueueStats> flow_misc_event_queue_;
std::vector<WorkQueueStats> flow_tokenless_queue_;
std::vector<WorkQueueStats> flow_delete_queue_;
std::vector<WorkQueueStats> flow_ksync_queue_;
std::vector<WorkQueueStats> flow_stats_queue_;
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/oper/agent_profile.sandesh
Expand Up @@ -108,7 +108,7 @@ struct SandeshFlowQueueSummaryInfo {
2: string time_str;
3: SandeshFlowTokenInfo token_stats;
4: SandeshFlowQueueSummaryOneInfo flow_event_queue;
5: SandeshFlowQueueSummaryOneInfo flow_misc_event_queue;
5: SandeshFlowQueueSummaryOneInfo flow_tokenless_queue;
6: SandeshFlowQueueSummaryOneInfo flow_ksync_queue;
7: SandeshFlowQueueSummaryOneInfo flow_delete_queue;
8: SandeshFlowQueueSummaryOneInfo flow_update_queue;
Expand Down
63 changes: 40 additions & 23 deletions src/vnsw/agent/pkt/flow_proto.cc
Expand Up @@ -42,7 +42,7 @@ FlowProto::FlowProto(Agent *agent, boost::asio::io_service &io) :
(new FlowEventQueue(agent, this, flow_table_list_[i],
&add_tokens_, latency, 16));

flow_misc_event_queue_.push_back
flow_tokenless_queue_.push_back
(new FlowEventQueue(agent, this, flow_table_list_[i],
NULL, latency, 16));

Expand All @@ -65,7 +65,7 @@ FlowProto::FlowProto(Agent *agent, boost::asio::io_service &io) :

FlowProto::~FlowProto() {
STLDeleteValues(&flow_event_queue_);
STLDeleteValues(&flow_misc_event_queue_);
STLDeleteValues(&flow_tokenless_queue_);
STLDeleteValues(&flow_delete_queue_);
STLDeleteValues(&flow_ksync_queue_);
STLDeleteValues(&flow_table_list_);
Expand Down Expand Up @@ -98,7 +98,7 @@ void FlowProto::Shutdown() {
}
for (uint32_t i = 0; i < flow_event_queue_.size(); i++) {
flow_event_queue_[i]->Shutdown();
flow_misc_event_queue_[i]->Shutdown();
flow_tokenless_queue_[i]->Shutdown();
flow_delete_queue_[i]->Shutdown();
flow_ksync_queue_[i]->Shutdown();
}
Expand Down Expand Up @@ -223,6 +223,7 @@ bool FlowProto::Enqueue(PktInfoPtr msg) {

void FlowProto::DisableFlowEventQueue(uint32_t index, bool disabled) {
flow_event_queue_[index]->set_disable(disabled);
flow_tokenless_queue_[index]->set_disable(disabled);
flow_delete_queue_[index]->set_disable(disabled);
}

Expand Down Expand Up @@ -301,12 +302,18 @@ void FlowProto::EnqueueFlowEvent(FlowEvent *event) {
break;
}

case FlowEvent::FLOW_MESSAGE:
case FlowEvent::FLOW_MESSAGE: {
FlowEntry *flow = event->flow();
FlowTable *table = flow->flow_table();
queue = flow_event_queue_[table->table_index()];
break;
}

case FlowEvent::EVICT_FLOW:
case FlowEvent::FREE_FLOW_REF: {
FlowEntry *flow = event->flow();
FlowTable *table = flow->flow_table();
queue = flow_event_queue_[table->table_index()];
queue = flow_tokenless_queue_[table->table_index()];
break;
}

Expand All @@ -318,23 +325,25 @@ void FlowProto::EnqueueFlowEvent(FlowEvent *event) {
}

case FlowEvent::GROW_FREE_LIST: {
FlowTable *table = GetTable(event->table_index());
queue = flow_event_queue_[table->table_index()];
queue = flow_tokenless_queue_[event->table_index()];
break;
}

case FlowEvent::KSYNC_EVENT: {
FlowEventKSync *ksync_event = static_cast<FlowEventKSync *>(event);
FlowTableKSyncObject *ksync_obj = static_cast<FlowTableKSyncObject *>
(ksync_event->ksync_entry()->GetObject());
FlowTable *table = ksync_obj->flow_table();
queue = flow_ksync_queue_[table->table_index()];
FlowTableKSyncEntry *ksync_entry =
(static_cast<FlowTableKSyncEntry *> (ksync_event->ksync_entry()));
FlowEntry *flow = ksync_entry->flow_entry().get();
FlowTable *table = flow->flow_table();
if (flow->flow_handle() == FlowEntry::kInvalidFlowHandle)
queue = flow_ksync_queue_[table->table_index()];
else
queue = flow_tokenless_queue_[table->table_index()];
break;
}

case FlowEvent::REENTRANT: {
uint32_t index = event->table_index();
queue = flow_event_queue_[index];
queue = flow_event_queue_[event->table_index()];
break;
}

Expand All @@ -344,7 +353,11 @@ void FlowProto::EnqueueFlowEvent(FlowEvent *event) {
break;
}

case FlowEvent::FREE_DBENTRY:
case FlowEvent::FREE_DBENTRY: {
queue = flow_tokenless_queue_[0];
break;
}

case FlowEvent::DELETE_DBENTRY:
case FlowEvent::RECOMPUTE_FLOW:
case FlowEvent::REVALUATE_DBENTRY: {
Expand Down Expand Up @@ -433,6 +446,16 @@ bool FlowProto::FlowEventHandler(FlowEvent *req, FlowTable *table) {
break;
}

case FlowEvent::KSYNC_EVENT: {
return FlowKSyncMsgHandler(req, table);
}

case FlowEvent::FREE_DBENTRY: {
FlowMgmtManager *mgr = agent()->pkt()->flow_mgmt_manager();
mgr->flow_mgmt_dbclient()->FreeDBState(req->db_entry(), req->gen_id());
break;
}

default: {
assert(0);
break;
Expand Down Expand Up @@ -471,12 +494,6 @@ bool FlowProto::FlowKSyncMsgHandler(FlowEvent *req, FlowTable *table) {

bool FlowProto::FlowUpdateHandler(FlowEvent *req) {
switch (req->event()) {
case FlowEvent::FREE_DBENTRY: {
FlowMgmtManager *mgr = agent()->pkt()->flow_mgmt_manager();
mgr->flow_mgmt_dbclient()->FreeDBState(req->db_entry(), req->gen_id());
break;
}

case FlowEvent::DELETE_DBENTRY:
case FlowEvent::REVALUATE_DBENTRY: {
FlowEntry *flow = req->flow();
Expand Down Expand Up @@ -799,15 +816,15 @@ void FlowProto::SetProfileData(ProfileData *data) {

data->flow_.flow_event_queue_.resize(flow_table_list_.size());
data->flow_.flow_delete_queue_.resize(flow_table_list_.size());
data->flow_.flow_misc_event_queue_.resize(flow_table_list_.size());
data->flow_.flow_tokenless_queue_.resize(flow_table_list_.size());
data->flow_.flow_ksync_queue_.resize(flow_table_list_.size());
for (uint16_t i = 0; i < flow_table_list_.size(); i++) {
SetFlowEventQueueStats(agent(), flow_event_queue_[i]->queue(),
&data->flow_.flow_event_queue_[i]);
SetFlowEventQueueStats(agent(), flow_delete_queue_[i]->queue(),
&data->flow_.flow_delete_queue_[i]);
SetFlowEventQueueStats(agent(), flow_misc_event_queue_[i]->queue(),
&data->flow_.flow_misc_event_queue_[i]);
SetFlowEventQueueStats(agent(), flow_tokenless_queue_[i]->queue(),
&data->flow_.flow_tokenless_queue_[i]);
SetFlowEventQueueStats(agent(), flow_ksync_queue_[i]->queue(),
&data->flow_.flow_ksync_queue_[i]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vnsw/agent/pkt/flow_proto.h
Expand Up @@ -133,7 +133,7 @@ class FlowProto : public Proto {
FlowTokenPool del_tokens_;
FlowTokenPool update_tokens_;
std::vector<FlowEventQueue *> flow_event_queue_;
std::vector<FlowEventQueue *> flow_misc_event_queue_;
std::vector<FlowEventQueue *> flow_tokenless_queue_;
std::vector<DeleteFlowEventQueue *> flow_delete_queue_;
std::vector<KSyncFlowEventQueue *> flow_ksync_queue_;
std::vector<FlowTable *> flow_table_list_;
Expand Down
6 changes: 3 additions & 3 deletions src/vnsw/agent/pkt/flow_table.cc
Expand Up @@ -534,10 +534,10 @@ void FlowTable::EvictFlow(FlowEntry *flow, FlowEntry *reverse_flow,
DeleteUnLocked(false, flow, NULL);

// Reverse flow unlinked with forward flow. Make it short-flow
if (reverse_flow && reverse_flow->deleted() == false) {
// Dont update ksync, it will shortly get either evicted or deleted by
// ageing process
if (reverse_flow)
reverse_flow->MakeShortFlow(FlowEntry::SHORT_NO_REVERSE_FLOW);
UpdateKSync(reverse_flow, true);
}
}

void FlowTable::HandleRevaluateDBEntry(const DBEntry *entry, FlowEntry *flow,
Expand Down

0 comments on commit a5b8e09

Please sign in to comment.