module ietf-diffserv-target {
  yang-version 1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-diffserv-target";
  prefix target;

  import ietf-interfaces {
    prefix if;
  }

  organization "IETF NETMOD (Netmod Working Group) Working Group";
  contact
    "WG Web:   <http://tools.ietf.org/wg/netmod/>
     WG List:  <mailto:netmod@ietf.org>

     WG Chair: Jurgen Schonwalder
               <mailto:j.schoenwaelder@jacobs-university.de>

     WG Chair: Tom Nadeau
               <mailto:tnadeau@lucidvision.com>

     Editor:   Aseem Choudhary
               <mailto:asechoud@cisco.com>

     Editor:   Shitanshu Shah
               <mailto:svshah@cisco.com>";
  description
    "This module contains a collection of YANG definitions for
     configuring diffserv specification implementations.

     Copyright (c) 2014 IETF Trust and the persons identified as
     authors of the code.  All rights reserved.

     Redistribution and use in source and binary forms, with or
     without modification, is permitted pursuant to, and subject
     to the license terms contained in, the Simplified BSD License
     set forth in Section 4.c of the IETF Trust's Legal Provisions
     Relating to IETF Documents
     (http://trustee.ietf.org/license-info).

     This version of this YANG module is part of RFC XXXX; see
     the RFC itself for full legal notices.";

  revision 2015-04-07 {
    description
      "Latest revision diffserv based policy applied to a target";
    reference "RFC XXXX";
  }

  identity direction {
    description
      "This is identity of traffic direction";
  }

  identity inbound {
    base direction;
    description
      "Direction of traffic coming into the network entry";
  }

  identity outbound {
    base direction;
    description
      "Direction of traffic going out of the network entry";
  }

  feature target-inline-policy-config {
    description
      "This feature allows the policy configuration
       directly under a target.";
  }

  grouping red-stats {
    description
      "RED Counters";
    leaf early-drop-pkts {
      type uint64;
      description
        "Early drop packets ";
    }
    leaf early-drop-bytes {
      type uint64;
      description
        "Early drop bytes ";
    }
  }

  grouping classifier-entry-stats {
    description
      "Classifier Counters";
    container classifier-entry-statistics {
      config false;
      description
        "
         This group defines the classifier filter statistics of
         each classifier entry

        ";
      leaf classified-pkts {
        type uint64;
        description
          " Number of total packets which filtered
            to the classifier-entry";
      }
      leaf classified-bytes {
        type uint64;
        description
          " Number of total bytes which filtered
            to the classifier-entry";
      }
      leaf classified-rate {
        type uint64;
        units "bits-per-second";
        description
          " Rate of average data flow through the
            classifier-entry";
      }
    }
  }

  grouping queuing-stats {
    description
      "Queuing Counters";
    container queuing-statistics {
      description
        "queue related statistics ";
      leaf output-pkts {
        type uint64;
        description
          "Number of packets transmitted from queue ";
      }
      leaf output-bytes {
        type uint64;
        description
          "Number of bytes transmitted from queue ";
      }
      leaf queue-size-pkts {
        type uint64;
        description
          "Number of packets currently buffered ";
      }
      leaf queue-size-bytes {
        type uint64;
        description
          "Number of bytes currently buffered ";
      }
      leaf drop-pkts {
        type uint64;
        description
          "Total number of packets dropped ";
      }
      leaf drop-bytes {
        type uint64;
        description
          "Total number of bytes dropped ";
      }
      container red-stats {
        uses red-stats;
        description
          "Container for RED statistics";
      }
    }
  }

  grouping meter-stats {
    description
      "Metering Counters";
    list meter-statistics {
      key "meter-id";
      description
        "Meter statistics";
      leaf meter-id {
        type uint16;
        description
          "Meter Identifier";
      }
      leaf meter-succeed-pkts {
        type uint64;
        description
          "Number of packets which succeed the meter";
      }
      leaf meter-succeed-bytes {
        type uint64;
        description
          "Bytes of packets which succeed the meter";
      }
      leaf meter-failed-pkts {
        type uint64;
        description
          "Number of packets which failed the meter";
      }
      leaf meter-failed-bytes {
        type uint64;
        description
          "Bytes of packets which failed the meter";
      }
    }
  }

  augment "/if:interfaces/if:interface" {
    description
      "Augments Diffserv Target Entry to Interface module";
    list diffserv-target-entry {
      key "direction policy-name";
      description
        "policy target for inbound or outbound direction";
      leaf direction {
        type identityref {
          base direction;
        }
        description
          "Direction fo the traffic flow either inbound or outbound";
      }
      leaf policy-name {
        type string;
        description
          "Policy entry name";
      }
      list diffserv-target-classifier-statistics {
        key "classifier-entry-name parent-path";
        config false;
        description
          "Statistics for each Classifier Entry in a Policy";
        leaf classifier-entry-name {
          type string;
          description
            "Classifier Entry Name";
        }
        leaf parent-path {
          type string;
          description
            "Path of the Classifier Entry in a hierarchial policy ";
        }
        uses classifier-entry-stats;
        uses meter-stats;
        uses queuing-stats;
      }
    }
  }
}
