]>
Commit | Line | Data |
---|---|---|
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 |
27 | struct netdev; |
28 | struct ovs_action_push_tnl; | |
29 | struct netdev_tnl_build_header_params; | |
30 | ||
6b241d64 PS |
31 | int |
32 | netdev_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 | 36 | void |
754f8acb WT |
37 | netdev_gre_push_header(const struct netdev *netdev, |
38 | struct dp_packet *packet, | |
6b241d64 | 39 | const struct ovs_action_push_tnl *data); |
1c8f98d9 | 40 | struct dp_packet * |
6b241d64 PS |
41 | netdev_gre_pop_header(struct dp_packet *packet); |
42 | ||
7dc18ae9 WT |
43 | int |
44 | netdev_erspan_build_header(const struct netdev *netdev, | |
45 | struct ovs_action_push_tnl *data, | |
46 | const struct netdev_tnl_build_header_params *p); | |
47 | ||
48 | void | |
49 | netdev_erspan_push_header(const struct netdev *netdev, | |
50 | struct dp_packet *packet, | |
51 | const struct ovs_action_push_tnl *data); | |
52 | struct dp_packet * | |
53 | netdev_erspan_pop_header(struct dp_packet *packet); | |
54 | ||
3c6d05a0 WT |
55 | struct dp_packet * |
56 | netdev_gtpu_pop_header(struct dp_packet *packet); | |
57 | ||
58 | void | |
59 | netdev_gtpu_push_header(const struct netdev *netdev, | |
60 | struct dp_packet *packet, | |
61 | const struct ovs_action_push_tnl *data); | |
62 | ||
63 | int | |
64 | netdev_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 | 68 | void |
754f8acb WT |
69 | netdev_tnl_push_udp_header(const struct netdev *netdev, |
70 | struct dp_packet *packet, | |
6b241d64 PS |
71 | const struct ovs_action_push_tnl *data); |
72 | int | |
73 | netdev_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 | 77 | struct dp_packet * |
6b241d64 PS |
78 | netdev_geneve_pop_header(struct dp_packet *packet); |
79 | ||
80 | int | |
81 | netdev_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 | 85 | struct dp_packet * |
6b241d64 PS |
86 | netdev_vxlan_pop_header(struct dp_packet *packet); |
87 | ||
88 | static inline bool | |
89 | netdev_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 | ||
96 | static inline struct ip_header * | |
97 | netdev_tnl_ip_hdr(void *eth) | |
98 | { | |
99 | return (void *)((char *)eth + sizeof (struct eth_header)); | |
100 | } | |
101 | ||
102 | static inline struct ovs_16aligned_ip6_hdr * | |
103 | netdev_tnl_ipv6_hdr(void *eth) | |
104 | { | |
105 | return (void *)((char *)eth + sizeof (struct eth_header)); | |
106 | } | |
107 | ||
4975aa3e PS |
108 | void * |
109 | netdev_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 |
113 | extern uint16_t tnl_udp_port_min; |
114 | extern uint16_t tnl_udp_port_max; | |
115 | ||
116 | static inline ovs_be16 | |
117 | netdev_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 | ||
127 | void * | |
128 | netdev_tnl_ip_extract_tnl_md(struct dp_packet *packet, struct flow_tnl *tnl, | |
129 | unsigned int *hlen); | |
130 | void * | |
131 | netdev_tnl_push_ip_header(struct dp_packet *packet, | |
132 | const void *header, int size, int *ip_tot_size); | |
133 | void | |
134 | netdev_tnl_egress_port_range(struct unixctl_conn *conn, int argc, | |
135 | const char *argv[], void *aux OVS_UNUSED); | |
136 | #endif |