Skip to content

Commit

Permalink
net: erspan: create erspan metadata uapi header
Browse files Browse the repository at this point in the history
The patch adds a new uapi header file, erspan.h, and moves
the 'struct erspan_metadata' from internal erspan.h to it.

Signed-off-by: William Tu <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
williamtu authored and davem330 committed Jan 26, 2018
1 parent c69de58 commit d350a82
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 30 deletions.
32 changes: 2 additions & 30 deletions include/net/erspan.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
* GRE proto ERSPAN type II = 0x88BE, type III = 0x22EB
*/

#include <uapi/linux/erspan.h>

#define ERSPAN_VERSION 0x1 /* ERSPAN type II */
#define VER_MASK 0xf000
#define VLAN_MASK 0x0fff
Expand All @@ -68,29 +70,6 @@
#define HWID_OFFSET 4
#define DIR_OFFSET 3

/* ERSPAN version 2 metadata header */
struct erspan_md2 {
__be32 timestamp;
__be16 sgt; /* security group tag */
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 hwid_upper:2,
ft:5,
p:1;
__u8 o:1,
gra:2,
dir:1,
hwid:4;
#elif defined(__BIG_ENDIAN_BITFIELD)
__u8 p:1,
ft:5,
hwid_upper:2;
__u8 hwid:4,
dir:1,
gra:2,
o:1;
#endif
};

enum erspan_encap_type {
ERSPAN_ENCAP_NOVLAN = 0x0, /* originally without VLAN tag */
ERSPAN_ENCAP_ISL = 0x1, /* originally ISL encapsulated */
Expand All @@ -100,13 +79,6 @@ enum erspan_encap_type {

#define ERSPAN_V1_MDSIZE 4
#define ERSPAN_V2_MDSIZE 8
struct erspan_metadata {
union {
__be32 index; /* Version 1 (type II)*/
struct erspan_md2 md2; /* Version 2 (type III) */
} u;
int version;
};

struct erspan_base_hdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
Expand Down
52 changes: 52 additions & 0 deletions include/uapi/linux/erspan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* ERSPAN Tunnel Metadata
*
* Copyright (c) 2018 VMware
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* Userspace API for metadata mode ERSPAN tunnel
*/
#ifndef _UAPI_ERSPAN_H
#define _UAPI_ERSPAN_H

#include <linux/types.h> /* For __beXX in userspace */
#include <asm/byteorder.h>

/* ERSPAN version 2 metadata header */
struct erspan_md2 {
__be32 timestamp;
__be16 sgt; /* security group tag */
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 hwid_upper:2,
ft:5,
p:1;
__u8 o:1,
gra:2,
dir:1,
hwid:4;
#elif defined(__BIG_ENDIAN_BITFIELD)
__u8 p:1,
ft:5,
hwid_upper:2;
__u8 hwid:4,
dir:1,
gra:2,
o:1;
#else
#error "Please fix <asm/byteorder.h>"
#endif
};

struct erspan_metadata {
int version;
union {
__be32 index; /* Version 1 (type II)*/
struct erspan_md2 md2; /* Version 2 (type III) */
} u;
};

#endif /* _UAPI_ERSPAN_H */

0 comments on commit d350a82

Please sign in to comment.