LCOV - code coverage report
Current view: top level - vnsw/agent/vrouter/ksync - ksync_flow_index_manager.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 5 5 100.0 %
Date: 2026-11-09 02:10:49 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14