1.. _vlan_interface: 2 3Virtual LAN (VLAN) Support 4########################## 5 6.. contents:: 7 :local: 8 :depth: 2 9 10Overview 11******** 12 13`Virtual LAN <https://wikipedia.org/wiki/Virtual_LAN>`_ (VLAN) is a 14partitioned and isolated computer network at the data link layer 15(OSI layer 2). For ethernet network this refers to 16`IEEE 802.1Q <https://en.wikipedia.org/wiki/IEEE_802.1Q>`_ 17 18In Zephyr, each individual VLAN is modeled as a virtual network interface. 19This means that there is an ethernet network interface that corresponds to 20a real physical ethernet port in the system. A virtual network interface is 21created for each VLAN, and this virtual network interface connects to the 22real network interface. This is similar to how Linux implements VLANs. The 23*eth0* is the real network interface and *vlan0* is a virtual network interface 24that is run on top of *eth0*. 25 26VLAN support must be enabled at compile time by setting option 27:kconfig:`CONFIG_NET_VLAN` and :kconfig:`CONFIG_NET_VLAN_COUNT` to reflect how 28many network interfaces there will be in the system. For example, if there is 29one network interface without VLAN support, and two with VLAN support, the 30:kconfig:`CONFIG_NET_VLAN_COUNT` option should be set to 3. 31 32Even if VLAN is enabled in a :file:`prj.conf` file, the VLAN needs to be 33activated at runtime by the application. The VLAN API provides a 34:c:func:`net_eth_vlan_enable` function to do that. The application needs 35to give the network interface and desired VLAN tag as a parameter to that 36function. The VLAN tagging for a given network interface can be disabled by a 37:c:func:`net_eth_vlan_disable` function. The application needs to configure 38the VLAN network interface itself, such as setting the IP address, etc. 39 40See also the :ref:`VLAN sample application <vlan-sample>` for API usage 41example. The source code for that sample application can be found at 42:zephyr_file:`samples/net/vlan`. 43 44The net-shell module contains *net vlan add* and *net vlan del* commands 45that can be used to enable or disable VLAN tags for a given network interface. 46 47See the `IEEE 802.1Q spec`_ for more information about ethernet VLANs. 48 49.. _IEEE 802.1Q spec: https://ieeexplore.ieee.org/document/6991462/ 50 51API Reference 52************* 53 54.. doxygengroup:: vlan_api 55