A bit of buffer metadata reshuffling to accommodate flow_id
[vpp.git] / src / vpp-api / vom / interface.hpp
index 8cba2fa..f6708b3 100644 (file)
@@ -31,7 +31,7 @@ namespace VOM {
  * Forward declaration of the stats and events command
  */
 namespace interface_cmds {
-class stats_cmd;
+class stats_enable_cmd;
 class events_cmd;
 };
 
@@ -41,6 +41,15 @@ class events_cmd;
 class interface : public object_base
 {
 public:
+  struct stats_type_t : public enum_base<stats_type_t>
+  {
+    const static stats_type_t DETAILED;
+    const static stats_type_t NORMAL;
+
+  private:
+    stats_type_t(int v, const std::string& s);
+  };
+
   /**
    * The key for interface's key
    */
@@ -58,7 +67,7 @@ public:
   struct type_t : enum_base<type_t>
   {
     /**
-     * Unkown type
+     * Unknown type
      */
     const static type_t UNKNOWN;
     /**
@@ -90,6 +99,16 @@ public:
      */
     const static type_t TAP;
 
+    /**
+     * vhost-user interface type
+     */
+    const static type_t VHOST;
+
+    /**
+     * bond interface type
+     */
+    const static type_t BOND;
+
     /**
      * Convert VPP's name of the interface to a type
      */
@@ -157,7 +176,10 @@ public:
   /**
    * Construct a new object matching the desried state
    */
-  interface(const std::string& name, type_t type, admin_state_t state);
+  interface(const std::string& name,
+            type_t type,
+            admin_state_t state,
+            const std::string& tag = "");
   /**
    * Construct a new object matching the desried state mapped
    * to a specific route_domain
@@ -165,7 +187,8 @@ public:
   interface(const std::string& name,
             type_t type,
             admin_state_t state,
-            const route_domain& rd);
+            const route_domain& rd,
+            const std::string& tag = "");
   /**
    * Destructor
    */
@@ -214,6 +237,11 @@ public:
    */
   const l2_address_t& l2_address() const;
 
+  /**
+   * Set the admin state of the interface
+   */
+  void set(const admin_state_t& state);
+
   /**
    * Set the L2 Address
    */
@@ -224,6 +252,11 @@ public:
    */
   void set(const oper_state_t& state);
 
+  /**
+   * Set the tag to the interface
+   */
+  void set(const std::string& tag);
+
   /**
    * Comparison operator - only used for UT
    */
@@ -335,7 +368,7 @@ public:
     void succeeded() {}
 
     /**
-     * add the created interface to the DB
+     * remove the deleted interface from the DB
      */
     void remove_interface() { interface::remove(this->item()); }
 
@@ -390,7 +423,8 @@ public:
      * Virtual function called on the listener when the command has data
      * ready to process
      */
-    virtual void handle_interface_stat(interface_cmds::stats_cmd* cmd) = 0;
+    virtual void handle_interface_stat(
+      interface_cmds::stats_enable_cmd* cmd) = 0;
 
     /**
      * Return the HW::item representing the status
@@ -422,17 +456,15 @@ public:
   /**
    * Enable stats for this interface
    */
-  void enable_stats(stat_listener& el);
+  void enable_stats(stat_listener& el,
+                    const stats_type_t& st = stats_type_t::NORMAL);
 
 protected:
   /**
-   * Construct an interface object with a handle and a HW address
+   * Set the handle of an interface object. Only called by the interface
+   * factory during the populate
    */
-  interface(const handle_t& handle,
-            const l2_address_t& l2_address,
-            const std::string& name,
-            type_t type,
-            admin_state_t state);
+  void set(const handle_t& handle);
   friend class interface_factory;
 
   /**
@@ -518,7 +550,7 @@ private:
   /**
    * enable the interface stats in the singular instance
    */
-  void enable_stats_i(stat_listener& el);
+  void enable_stats_i(stat_listener& el, const stats_type_t& st);
 
   /**
    * Commit the acculmulated changes into VPP. i.e. to a 'HW" write.
@@ -560,7 +592,7 @@ private:
   /**
    * shared pointer to the stats object for this interface.
    */
-  std::shared_ptr<interface_cmds::stats_cmd> m_stats;
+  std::shared_ptr<interface_cmds::stats_enable_cmd> m_stats;
 
   /**
    * The state of the interface
@@ -577,11 +609,21 @@ private:
    */
   HW::item<l2_address_t> m_l2_address;
 
+  /**
+   * The state of the detailed stats collection
+   */
+  HW::item<stats_type_t> m_stats_type;
+
   /**
    * Operational state of the interface
    */
   oper_state_t m_oper;
 
+  /**
+   * tag of the interface
+   */
+  std::string m_tag;
+
   /**
    * A map of all interfaces keyed against VPP's handle
    */