xref: /src/sys/compat/linuxkpi/common/include/linux/if_vlan.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1aa0a1e58SJeff Roberson /*-
2aa0a1e58SJeff Roberson  * Copyright (c) 2010 Isilon Systems, Inc.
3aa0a1e58SJeff Roberson  * Copyright (c) 2010 iX Systems, Inc.
4aa0a1e58SJeff Roberson  * Copyright (c) 2010 Panasas, Inc.
5f15ffb5eSHans Petter Selasky  * Copyright (c) 2013-2016 Mellanox Technologies, Ltd.
6aa0a1e58SJeff Roberson  * All rights reserved.
7aa0a1e58SJeff Roberson  *
8aa0a1e58SJeff Roberson  * Redistribution and use in source and binary forms, with or without
9aa0a1e58SJeff Roberson  * modification, are permitted provided that the following conditions
10aa0a1e58SJeff Roberson  * are met:
11aa0a1e58SJeff Roberson  * 1. Redistributions of source code must retain the above copyright
12aa0a1e58SJeff Roberson  *    notice unmodified, this list of conditions, and the following
13aa0a1e58SJeff Roberson  *    disclaimer.
14aa0a1e58SJeff Roberson  * 2. Redistributions in binary form must reproduce the above copyright
15aa0a1e58SJeff Roberson  *    notice, this list of conditions and the following disclaimer in the
16aa0a1e58SJeff Roberson  *    documentation and/or other materials provided with the distribution.
17aa0a1e58SJeff Roberson  *
18aa0a1e58SJeff Roberson  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19aa0a1e58SJeff Roberson  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20aa0a1e58SJeff Roberson  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21aa0a1e58SJeff Roberson  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22aa0a1e58SJeff Roberson  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23aa0a1e58SJeff Roberson  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24aa0a1e58SJeff Roberson  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25aa0a1e58SJeff Roberson  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26aa0a1e58SJeff Roberson  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27aa0a1e58SJeff Roberson  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28aa0a1e58SJeff Roberson  */
29307f78f3SVladimir Kondratyev #ifndef	_LINUXKPI_LINUX_IF_VLAN_H_
30307f78f3SVladimir Kondratyev #define	_LINUXKPI_LINUX_IF_VLAN_H_
31aa0a1e58SJeff Roberson 
328e7baabcSHans Petter Selasky #include <sys/types.h>
33c7818b48SHans Petter Selasky #include <sys/socket.h>
34c7818b48SHans Petter Selasky #include <net/if.h>
35aa0a1e58SJeff Roberson #include <net/ethernet.h>
36f15ffb5eSHans Petter Selasky #include <net/if_var.h>
37aa0a1e58SJeff Roberson #include <net/if_vlan_var.h>
38f15ffb5eSHans Petter Selasky #include <net/if_types.h>
39aa0a1e58SJeff Roberson 
40c7818b48SHans Petter Selasky #define VLAN_N_VID	4096
41c7818b48SHans Petter Selasky 
42f15ffb5eSHans Petter Selasky static inline int
is_vlan_dev(struct ifnet * ifp)43f15ffb5eSHans Petter Selasky is_vlan_dev(struct ifnet *ifp)
44f15ffb5eSHans Petter Selasky {
4597583aa2SJustin Hibbits 	return (if_gettype(ifp) == IFT_L2VLAN);
46f15ffb5eSHans Petter Selasky }
47f15ffb5eSHans Petter Selasky 
48f15ffb5eSHans Petter Selasky static inline uint16_t
vlan_dev_vlan_id(struct ifnet * ifp)49f15ffb5eSHans Petter Selasky vlan_dev_vlan_id(struct ifnet *ifp)
50f15ffb5eSHans Petter Selasky {
51f15ffb5eSHans Petter Selasky 	uint16_t vtag;
52f15ffb5eSHans Petter Selasky 	if (VLAN_TAG(ifp, &vtag) == 0)
53f15ffb5eSHans Petter Selasky 		return (vtag);
54f15ffb5eSHans Petter Selasky 	return (0);
55f15ffb5eSHans Petter Selasky }
56f15ffb5eSHans Petter Selasky 
57307f78f3SVladimir Kondratyev #endif	/* _LINUXKPI_LINUX_IF_VLAN_H_ */
58