]> git.proxmox.com Git - mirror_ovs.git/blame - lib/netdev-native-tnl.h
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / lib / netdev-native-tnl.h
CommitLineData
6b241d64
PS
1/*
2 * Copyright (c) 2010, 2011, 2013, 2015 Nicira, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef NETDEV_VPORT_NATIVE_TNL_H
18#define NETDEV_VPORT_NATIVE_TNL_H 1
19
20#include <stdbool.h>
21#include <stddef.h>
22#include "compiler.h"
aca40d4f
TLSC
23#include "dp-packet.h"
24#include "packets.h"
6b241d64
PS
25#include "unixctl.h"
26
aca40d4f
TLSC
27struct netdev;
28struct ovs_action_push_tnl;
29struct netdev_tnl_build_header_params;
30
6b241d64
PS
31int
32netdev_gre_build_header(const struct netdev *netdev,
33 struct ovs_action_push_tnl *data,
4975aa3e
PS
34 const struct netdev_tnl_build_header_params *params);
35
6b241d64 36void
754f8acb
WT
37netdev_gre_push_header(const struct netdev *netdev,
38 struct dp_packet *packet,
6b241d64 39 const struct ovs_action_push_tnl *data);
1c8f98d9 40struct dp_packet *
6b241d64
PS
41netdev_gre_pop_header(struct dp_packet *packet);
42
7dc18ae9
WT
43int
44netdev_erspan_build_header(const struct netdev *netdev,
45 struct ovs_action_push_tnl *data,
46 const struct netdev_tnl_build_header_params *p);
47
48void
49netdev_erspan_push_header(const struct netdev *netdev,
50 struct dp_packet *packet,
51 const struct ovs_action_push_tnl *data);
52struct dp_packet *
53netdev_erspan_pop_header(struct dp_packet *packet);
54
3c6d05a0
WT
55struct dp_packet *
56netdev_gtpu_pop_header(struct dp_packet *packet);
57
58void
59netdev_gtpu_push_header(const struct netdev *netdev,
60 struct dp_packet *packet,
61 const struct ovs_action_push_tnl *data);
62
63int
64netdev_gtpu_build_header(const struct netdev *netdev,
65 struct ovs_action_push_tnl *data,
66 const struct netdev_tnl_build_header_params *p);
67
6b241d64 68void
754f8acb
WT
69netdev_tnl_push_udp_header(const struct netdev *netdev,
70 struct dp_packet *packet,
6b241d64
PS
71 const struct ovs_action_push_tnl *data);
72int
73netdev_geneve_build_header(const struct netdev *netdev,
74 struct ovs_action_push_tnl *data,
4975aa3e
PS
75 const struct netdev_tnl_build_header_params *params);
76
1c8f98d9 77struct dp_packet *
6b241d64
PS
78netdev_geneve_pop_header(struct dp_packet *packet);
79
80int
81netdev_vxlan_build_header(const struct netdev *netdev,
82 struct ovs_action_push_tnl *data,
4975aa3e
PS
83 const struct netdev_tnl_build_header_params *params);
84
1c8f98d9 85struct dp_packet *
6b241d64
PS
86netdev_vxlan_pop_header(struct dp_packet *packet);
87
88static inline bool
89netdev_tnl_is_header_ipv6(const void *header)
90{
91 const struct eth_header *eth;
92 eth = header;
93 return eth->eth_type == htons(ETH_TYPE_IPV6);
94}
95
96static inline struct ip_header *
97netdev_tnl_ip_hdr(void *eth)
98{
99 return (void *)((char *)eth + sizeof (struct eth_header));
100}
101
102static inline struct ovs_16aligned_ip6_hdr *
103netdev_tnl_ipv6_hdr(void *eth)
104{
105 return (void *)((char *)eth + sizeof (struct eth_header));
106}
107
4975aa3e
PS
108void *
109netdev_tnl_ip_build_header(struct ovs_action_push_tnl *data,
110 const struct netdev_tnl_build_header_params *params,
111 uint8_t next_proto);
112
6b241d64
PS
113extern uint16_t tnl_udp_port_min;
114extern uint16_t tnl_udp_port_max;
115
116static inline ovs_be16
117netdev_tnl_get_src_port(struct dp_packet *packet)
118{
119 uint32_t hash;
120
121 hash = dp_packet_get_rss_hash(packet);
122
123 return htons((((uint64_t) hash * (tnl_udp_port_max - tnl_udp_port_min)) >> 32) +
124 tnl_udp_port_min);
125}
126
127void *
128netdev_tnl_ip_extract_tnl_md(struct dp_packet *packet, struct flow_tnl *tnl,
129 unsigned int *hlen);
130void *
131netdev_tnl_push_ip_header(struct dp_packet *packet,
132 const void *header, int size, int *ip_tot_size);
133void
134netdev_tnl_egress_port_range(struct unixctl_conn *conn, int argc,
135 const char *argv[], void *aux OVS_UNUSED);
136#endif