LCOV - code coverage report
Current view: top level - vnsw/agent/oper - qos_config.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 10 59 16.9 %
Date: 2026-11-09 02:10:49 Functions: 4 24 16.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
       3             :  * Copyright Contributors to the OpenSDN project
       4             :  */
       5             : 
       6             : #ifndef __AGENT_OPER_QOS_CONFIG_H
       7             : #define __AGENT_OPER_QOS_CONFIG_H
       8             : 
       9             : #include <cmn/agent.h>
      10             : #include <oper_db.h>
      11             : #include <cmn/index_vector.h>
      12             : 
      13             : class Agent;
      14             : class DB;
      15             : class AgentQosConfigTable;
      16             : struct AgentQosConfigData;
      17             : 
      18             : struct AgentQosConfigKey : public AgentOperDBKey {
      19        1976 :     AgentQosConfigKey(const boost::uuids::uuid &uuid):
      20        1976 :         uuid_(uuid) {}
      21             : 
      22             :     AgentQosConfigKey(const AgentQosConfigKey &rhs):
      23             :         uuid_(rhs.uuid_) {}
      24             : 
      25             :     bool IsLess(const AgentQosConfigKey &rhs) const {
      26             :         return uuid_ < rhs.uuid_;
      27             :     }
      28             : 
      29             :     boost::uuids::uuid uuid_;
      30             : };
      31             : 
      32             : typedef std::pair<uint32_t, uint32_t> AgentQosIdForwardingClassPair;
      33             : typedef std::map<uint32_t, uint32_t> AgentQosIdForwardingClassMap;
      34             : 
      35             : class AgentQosConfig :
      36             :     AgentRefCount<AgentQosConfig>, public AgentOperDBEntry {
      37             : public:
      38             :     static const uint32_t kDefaultQosMsgSize = 4098;
      39             :     typedef enum {
      40             :         VHOST,
      41             :         FABRIC,
      42             :         DEFAULT
      43             :     } Type;
      44             :     typedef std::pair<uint32_t, uint32_t> QosIdForwardingClassPair;
      45             :     typedef std::map<uint32_t, uint32_t> QosIdForwardingClassMap;
      46             : 
      47             :     AgentQosConfig(const boost::uuids::uuid uuid);
      48             :     virtual ~AgentQosConfig();
      49             : 
      50             :     KeyPtr GetDBRequestKey() const;
      51             :     std::string ToString() const;
      52             :     virtual bool IsLess(const DBEntry &rhs) const;
      53             :     virtual bool DBEntrySandesh(Sandesh *resp, std::string &name) const;
      54             : 
      55             :     virtual bool Change(const DBRequest *req);
      56             :     virtual void Delete(const DBRequest *req);
      57             :     virtual void SetKey(const DBRequestKey *key);
      58             : 
      59           0 :     virtual bool DeleteOnZeroRefCount() const {
      60           0 :         return false;
      61             :     }
      62           0 :     virtual void OnZeroRefCount() {};
      63           0 :     uint32_t GetRefCount() const {
      64           0 :         return AgentRefCount<AgentQosConfig>::GetRefCount();
      65             :     }
      66             : 
      67           0 :     boost::uuids::uuid uuid() const {
      68           0 :         return uuid_;
      69             :     }
      70             : 
      71           0 :     void set_id(uint32_t id) {
      72           0 :         id_ = id;
      73           0 :     }
      74           0 :     uint32_t id() const {
      75           0 :         return id_;
      76             :     }
      77             : 
      78           0 :     std::string name() const {
      79           0 :         return name_;
      80             :     }
      81             : 
      82          37 :     const QosIdForwardingClassMap& dscp_map() const {
      83          37 :         return dscp_map_;
      84             :     }
      85             : 
      86           0 :     const QosIdForwardingClassMap& vlan_priority_map() const {
      87           0 :         return vlan_priority_map_;
      88             :     }
      89             : 
      90           0 :     const QosIdForwardingClassMap& mpls_exp_map() const {
      91           0 :         return mpls_exp_map_;
      92             :     }
      93             : 
      94           0 :     Type type() const {
      95           0 :         return type_;
      96             :     }
      97             : 
      98           0 :     uint32_t default_forwarding_class() const {
      99           0 :         return default_forwarding_class_;
     100             :     }
     101             : 
     102             :     int MsgLen() { return kDefaultQosMsgSize; }
     103             : 
     104             : private:
     105             :     bool VerifyLinkToGlobalQosConfig(const Agent *agent,
     106             :                                      const AgentQosConfigData *data);
     107             :     void HandleVhostQosConfig(const Agent *agent,
     108             :                               const AgentQosConfigData *data, bool deleted);
     109             :     void HandleFabricQosConfig(const Agent *agent,
     110             :                                const AgentQosConfigData *data, bool deleted);
     111             :     void HandleGlobalQosConfig(const AgentQosConfigData *data);
     112             :     bool HandleQosForwardingMapChange(const Agent *agent,
     113             :                                       QosIdForwardingClassMap &map,
     114             :                                       const AgentQosIdForwardingClassMap &data_map);
     115             :     boost::uuids::uuid uuid_;
     116             :     std::string name_;
     117             :     uint32_t id_;
     118             :     QosIdForwardingClassMap dscp_map_;
     119             :     QosIdForwardingClassMap vlan_priority_map_;
     120             :     QosIdForwardingClassMap mpls_exp_map_;
     121             :     Type type_;
     122             :     uint32_t default_forwarding_class_;
     123             :     DISALLOW_COPY_AND_ASSIGN(AgentQosConfig);
     124             : };
     125             : 
     126             : struct AgentQosConfigData : public AgentOperDBData {
     127           0 :     AgentQosConfigData(const Agent *agent, IFMapNode *node) :
     128           0 :     AgentOperDBData(agent, node), default_forwarding_class_(0) {}
     129             : 
     130             :     std::string name_;
     131             :     AgentQosIdForwardingClassMap dscp_map_;
     132             :     AgentQosIdForwardingClassMap vlan_priority_map_;
     133             :     AgentQosIdForwardingClassMap mpls_exp_map_;
     134             :     AgentQosConfig::Type type_;
     135             :     uint32_t default_forwarding_class_;
     136             : };
     137             : 
     138             : class AgentQosConfigTable : public AgentOperDBTable {
     139             : public:
     140             :     typedef std::map<std::string, AgentQosConfig*> AgentQosConfigNameMap;
     141             :     typedef std::pair<std::string, AgentQosConfig*> AgentQosConfigNamePair;
     142             : 
     143             :     AgentQosConfigTable(Agent *agent, DB *db, const std::string &name);
     144             :     virtual ~AgentQosConfigTable();
     145             :     static const uint32_t kInvalidIndex=0xFFFF;
     146             :     static const uint32_t kDscpEntries = 63;
     147             :     static const uint32_t k801pEntries = 7;
     148             :     static const uint32_t kExpEntries = 7;
     149             : 
     150             : 
     151             :     static DBTableBase *CreateTable(Agent *agent, DB *db,
     152             :                                     const std::string &name);
     153             : 
     154             :     virtual std::unique_ptr<DBEntry> AllocEntry(const DBRequestKey *k) const;
     155             : 
     156           0 :     virtual size_t Hash(const DBEntry *entry) const {return 0;}
     157        1976 :     virtual size_t Hash(const DBRequestKey *key) const {return 0;}
     158             : 
     159             :     virtual DBEntry *OperDBAdd(const DBRequest *req);
     160             :     virtual bool OperDBOnChange(DBEntry *entry, const DBRequest *req);
     161             :     virtual bool OperDBDelete(DBEntry *entry, const DBRequest *req);
     162             :     virtual bool OperDBResync(DBEntry *entry, const DBRequest *req);
     163             : 
     164             :     virtual bool IFNodeToReq(IFMapNode *node, DBRequest &req,
     165             :                              const boost::uuids::uuid &u);
     166             :     virtual bool IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u);
     167             :     virtual bool ProcessConfig(IFMapNode *node, DBRequest &req,
     168             :                                const boost::uuids::uuid &u);
     169             :     AgentQosConfigData* BuildData(IFMapNode *node);
     170             :     void ReleaseIndex(AgentQosConfig *qc);
     171             :     virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args,
     172             :                                             const std::string &context);
     173             : 
     174          12 :     const AgentQosConfig* FindByName(const std::string &name) {
     175          12 :         AgentQosConfigNameMap::const_iterator it = name_map_.find(name);
     176          12 :         if (it == name_map_.end()) {
     177           8 :             return NULL;
     178             :         }
     179           4 :         return it->second;
     180             :     }
     181             : 
     182           0 :     const AgentQosConfig* FindByIndex(uint32_t idx) const {
     183           0 :         return index_table_.At(idx);
     184             :     }
     185             : 
     186           0 :     void EraseFabricQosConfig(const boost::uuids::uuid &uuid) {
     187           0 :         fabric_qos_config_uuids_.erase(uuid);
     188           0 :     }
     189             : 
     190           0 :     void InsertFabricQosConfig(const boost::uuids::uuid &uuid) {
     191           0 :         fabric_qos_config_uuids_.insert(uuid);
     192           0 :     }
     193             : 
     194           0 :     const boost::uuids::uuid GetActiveFabricQosConfig() {
     195             :         std::set<boost::uuids::uuid>::const_iterator it =
     196           0 :             fabric_qos_config_uuids_.begin();
     197           0 :         if (it == fabric_qos_config_uuids_.end()) {
     198           0 :             return boost::uuids::nil_uuid();
     199             :         }
     200           0 :         return *it;
     201             :     }
     202             : 
     203           0 :     void EraseVhostQosConfig(const boost::uuids::uuid &uuid) {
     204           0 :         vhost_qos_config_uuids_.erase(uuid);
     205           0 :     }
     206             : 
     207           0 :     void InsertVhostQosConfig(const boost::uuids::uuid &uuid) {
     208           0 :         vhost_qos_config_uuids_.insert(uuid);
     209           0 :     }
     210             : 
     211           0 :     const boost::uuids::uuid GetActiveVhostQosConfig() {
     212             :         std::set<boost::uuids::uuid>::const_iterator it =
     213           0 :             vhost_qos_config_uuids_.begin();
     214           0 :         if (it == vhost_qos_config_uuids_.end()) {
     215           0 :             return boost::uuids::nil_uuid();
     216             :         }
     217           0 :         return *it;
     218             :     }
     219             : private:
     220             :     AgentQosConfigNameMap name_map_;
     221             :     std::set<boost::uuids::uuid> vhost_qos_config_uuids_;
     222             :     std::set<boost::uuids::uuid> fabric_qos_config_uuids_;
     223             :     IndexVector<AgentQosConfig *> index_table_;
     224             :     DISALLOW_COPY_AND_ASSIGN(AgentQosConfigTable);
     225             : };
     226             : #endif

Generated by: LCOV version 1.14