OpenSDN source code
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 <mutex>
8 
9 #include <pkt/flow_entry.h>
10 
12 // The module is responsible to manage assignment of vrouter flow-table index
13 // to the flow.
14 //
15 // The module maintains following information,
16 //
17 // KSyncFlowIndexManager::IndexTree
18 // Common table containing information about which flow owns the index.
19 // Each entry in tree is of type KSyncFlowIndexManager::IndexEntry.
20 // It contains,
21 // owner_ : Flow owning the index
23 class FlowEntry;
24 class FlowProto;
27 class SandeshFlowIndexInfo;
28 
30 public:
31  // use buffer of 127 (half of the gen-id range) to identify Active
32  // gen id while accounting for roll-over of gen-id
33  static const uint8_t kActiveGenIdDiffMax = 127;
34 
35  struct IndexEntry {
36  IndexEntry() : owner_(NULL) { }
37  virtual ~IndexEntry() {
38  assert(owner_.get() == NULL);
39  }
40  // copy-contructor is needed by std::vector but should never be used
41  IndexEntry(const IndexEntry& i) {
42  assert(0);
43  }
44 
45  std::mutex mutex_;
47  };
49  virtual ~KSyncFlowIndexManager();
50  void InitDone(uint32_t count);
51 
52  FlowEntryPtr FindByIndex(uint32_t idx);
53 
54  void Update(FlowEntry *flow);
55  void Delete(FlowEntry *flow);
56  void DisableSend(FlowEntry *flow, uint8_t evict_gen_id);
57  void UpdateFlowHandle(FlowTableKSyncEntry *kentry, uint32_t index,
58  uint8_t gen_id);
61 
62  uint16_t sm_log_count() const { return sm_log_count_; }
63 
64 private:
65  uint8_t AcquireIndexUnLocked(uint32_t index, uint8_t gen_id,
66  FlowEntry *flow);
67  void ReleaseIndexUnLocked(FlowEntry *flow);
68 
69  void CreateInternal(FlowEntry *flow);
70 
73  uint32_t count_;
75  uint16_t sm_log_count_;
76 };
77 
78 #endif // __VNSW_AGENT_VROUTER_KSYNC_KSYNC_FLOW_INDEX_MANAGER_H__
void ReleaseIndexUnLocked(FlowEntry *flow)
void TriggerKSyncEvent(FlowTableKSyncEntry *kentry, KSyncEntry::KSyncEvent event)
void DisableSend(FlowEntry *flow, uint8_t evict_gen_id)
void Update(FlowEntry *flow)
void Delete(FlowEntry *flow)
struct IndexEntry * index_list_
FlowEntryPtr FindByIndex(uint32_t idx)
void CreateInternal(FlowEntry *flow)
uint8_t AcquireIndexUnLocked(uint32_t index, uint8_t gen_id, FlowEntry *flow)
void InitDone(uint32_t count)
void UpdateFlowHandle(FlowTableKSyncEntry *kentry, uint32_t index, uint8_t gen_id)
static const uint8_t kActiveGenIdDiffMax
boost::intrusive_ptr< FlowEntry > FlowEntryPtr
Definition: flow_entry.h:125