submodule infix-if-vlan {
  yang-version 1.1;
  belongs-to infix-interfaces {
    prefix infix-if;
  }

  import ietf-interfaces {
    prefix if;
  }

  import infix-if-type {
    prefix infixift;
  }
  import ieee802-dot1q-types {
    prefix dot1q-types;
  }
  contact      "kernelkit@googlegroups.com";
  description
    "This module implements VLAN (8021q) encapsulation";

  revision 2024-05-30 {
    description "Added basic QoS policy

                 Support for mapping the Priority Code Point (PCP) to
                 internal priority on ingress, and the reverse on
                 egress.";
  }

  revision 2023-10-25 {
    description "Initial revision";
  }

  augment "/if:interfaces/if:interface" {
    when "derived-from-or-self(if:type, 'infixift:vlan')" {
      description "Only shown for if:type vlan";
    }
    description "Augment to add  802.1Q VLAN tag classifications";
    container vlan {
      description "Configure 802.1q/802.1ad VLANs";
      leaf tag-type {
        type dot1q-types:dot1q-tag-type;
        default dot1q-types:c-vlan;
        description "VLAN type";
      }
      leaf id {
        type dot1q-types:vlanid;
        mandatory true;
        description "VLAN Id";
      }
      leaf lower-layer-if {
        type if:interface-ref;
        mandatory true;
        description "Base interface for VLAN";
      }
      container ingress-qos {
        leaf priority {
          description "Internal priority assignment

                       The policy by which ingressing packets'
                       internal priority is determined. Supported
                       modes are to use a fixed value for all packets,
                       or to derive it from the packet's Priority Code
                       Point (PCP) field.";

          type union {
            type uint8 {
              range "0..7";
            }
            type enumeration {
              enum from-pcp {
                description "Map PCP 1:1 to internal priority";
              }
            }
          }
          default 0;
        }
      }
      container egress-qos {
        leaf pcp {
          description "Priority Code Point (PCP) assignment

                       The policy by which egressing packets' PCP
                       field is determined. Supported modes are to use
                       a fixed value for all packets, or to derive it
                       from the packet's internal priority.";
          type union {
            type uint8 {
              range "0..7";
            }
            type enumeration {
              enum from-priority {
                description "Map internal priority 1:1 to PCP";
              }
            }
          }
          default 0;
        }
      }
    }
  }
}
