OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ksync_flow_index_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3  */
4 #ifndef __VNSW_AGENT_VROUTER_KSYNC_KSYNC_FLOW_INDEX_MANAGER_H__
5 #define __VNSW_AGENT_VROUTER_KSYNC_KSYNC_FLOW_INDEX_MANAGER_H__
6 
7 #include <tbb/mutex.h>
8 #include <pkt/flow_entry.h>
9 
11 // The module is responsible to manage assignment of vrouter flow-table index
12 // to the flow.
13 //
14 // The module maintains following information,
15 //
16 // KSyncFlowIndexManager::IndexTree
17 // Common table containing information about which flow owns the index.
18 // Each entry in tree is of type KSyncFlowIndexManager::IndexEntry.
19 // It contains,
20 // owner_ : Flow owning the index
22 class FlowEntry;
23 class FlowProto;
26 class SandeshFlowIndexInfo;
27 
29 public:
30  // use buffer of 127 (half of the gen-id range) to identify Active
31  // gen id while accounting for roll-over of gen-id
32  static const uint8_t kActiveGenIdDiffMax = 127;
33 
34  struct IndexEntry {
35  IndexEntry() : owner_(NULL) { }
36  virtual ~IndexEntry() {
37  assert(owner_.get() == NULL);
38  }
39  // copy-contructor is needed by std::vector but should never be used
40  IndexEntry(const IndexEntry& i) {
41  assert(0);
42  }
43 
44  tbb::mutex mutex_;
46  };
48  virtual ~KSyncFlowIndexManager();
49  void InitDone(uint32_t count);
50 
51  FlowEntryPtr FindByIndex(uint32_t idx);
52 
53  void Update(FlowEntry *flow);
54  void Delete(FlowEntry *flow);
55  void DisableSend(FlowEntry *flow, uint8_t evict_gen_id);
56  void UpdateFlowHandle(FlowTableKSyncEntry *kentry, uint32_t index,
57  uint8_t gen_id);
60 
61  uint16_t sm_log_count() const { return sm_log_count_; }
62 
63 private:
64  uint8_t AcquireIndexUnLocked(uint32_t index, uint8_t gen_id,
65  FlowEntry *flow);
66  void ReleaseIndexUnLocked(FlowEntry *flow);
67 
68  void CreateInternal(FlowEntry *flow);
69 
72  uint32_t count_;
74  uint16_t sm_log_count_;
75 };
76 
77 #endif // __VNSW_AGENT_VROUTER_KSYNC_KSYNC_FLOW_INDEX_MANAGER_H__
void Delete(FlowEntry *flow)
FlowEntryPtr FindByIndex(uint32_t idx)
struct IndexEntry * index_list_
void CreateInternal(FlowEntry *flow)
void InitDone(uint32_t count)
void Update(FlowEntry *flow)
void UpdateFlowHandle(FlowTableKSyncEntry *kentry, uint32_t index, uint8_t gen_id)
void TriggerKSyncEvent(FlowTableKSyncEntry *kentry, KSyncEntry::KSyncEvent event)
void ReleaseIndexUnLocked(FlowEntry *flow)
static const uint8_t kActiveGenIdDiffMax
void DisableSend(FlowEntry *flow, uint8_t evict_gen_id)
uint8_t AcquireIndexUnLocked(uint32_t index, uint8_t gen_id, FlowEntry *flow)
boost::intrusive_ptr< FlowEntry > FlowEntryPtr
Definition: flow_entry.h:125