~ubuntu-branches/ubuntu/wily/openvswitch/wily

« back to all changes in this revision

Viewing changes to lib/odp-util.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-08-10 11:35:15 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20150810113515-575vj06oq29emxsn
Tags: 2.4.0~git20150810.97bab95-0ubuntu1
* New upstream snapshot from 2.4 branch:
  - d/*: Align any relevant packaging changes with upstream.
* d/*: wrap-and-sort.
* d/openvswitch-{common,vswitch}.install: Correct install location for
  bash completion files.
* d/tests/openflow.py: Explicitly use ovs-testcontroller as provided
  by 2.4.0 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
 
2
 * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
3
3
 *
4
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
5
 * you may not use this file except in compliance with the License.
21
21
#include <stddef.h>
22
22
#include <stdint.h>
23
23
#include <string.h>
24
 
#include <linux/openvswitch.h>
 
24
#include "flow.h"
25
25
#include "hash.h"
26
26
#include "hmap.h"
 
27
#include "odp-netlink.h"
27
28
#include "openflow/openflow.h"
28
29
#include "util.h"
29
30
 
30
31
struct ds;
31
 
struct flow;
32
 
struct flow_tnl;
33
 
struct flow_wildcards;
34
32
struct nlattr;
35
33
struct ofpbuf;
36
34
struct simap;
42
40
    SPR(SLOW_BFD,        "bfd",        "Consists of BFD packets")       \
43
41
    SPR(SLOW_LACP,       "lacp",       "Consists of LACP packets")      \
44
42
    SPR(SLOW_STP,        "stp",        "Consists of STP packets")       \
 
43
    SPR(SLOW_LLDP,       "lldp",       "Consists of LLDP packets")    \
45
44
    SPR(SLOW_CONTROLLER, "controller",                                  \
46
45
        "Sends \"packet-in\" messages to the OpenFlow controller")      \
47
46
    SPR(SLOW_ACTION,     "action",                                      \
64
63
#undef SPR
65
64
};
66
65
 
 
66
/* Mask of all slow_path_reasons. */
 
67
enum {
 
68
    SLOW_PATH_REASON_MASK = 0
 
69
#define SPR(ENUM, STRING, EXPLANATION) | 1 << ENUM##_INDEX 
 
70
    SLOW_PATH_REASONS
 
71
#undef SPR
 
72
};
 
73
 
67
74
const char *slow_path_reason_to_explanation(enum slow_path_reason);
68
75
 
69
76
#define ODPP_LOCAL ODP_PORT_C(OVSP_LOCAL)
106
113
 *  - OVS_TUNNEL_KEY_ATTR_TTL            1    3      4      8
107
114
 *  - OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT  0    --     4      4
108
115
 *  - OVS_TUNNEL_KEY_ATTR_CSUM           0    --     4      4
 
116
 *  - OVS_TUNNEL_KEY_ATTR_OAM            0    --     4      4
 
117
 *  - OVS_TUNNEL_KEY_ATTR_GENEVE_OPTS    256  --     4      260
 
118
 *  - OVS_TUNNEL_KEY_ATTR_VXLAN_OPTS     -    --     -      - (shared with _GENEVE_OPTS)
109
119
 *  OVS_KEY_ATTR_IN_PORT                 4    --     4      8
110
120
 *  OVS_KEY_ATTR_SKB_MARK                4    --     4      8
 
121
 *  OVS_KEY_ATTR_DP_HASH                 4    --     4      8
 
122
 *  OVS_KEY_ATTR_RECIRC_ID               4    --     4      8
111
123
 *  OVS_KEY_ATTR_ETHERNET               12    --     4     16
112
124
 *  OVS_KEY_ATTR_ETHERTYPE               2     2     4      8  (outer VLAN ethertype)
113
 
 *  OVS_KEY_ATTR_8021Q                   4    --     4      8
 
125
 *  OVS_KEY_ATTR_VLAN                    2     2     4      8
114
126
 *  OVS_KEY_ATTR_ENCAP                   0    --     4      4  (VLAN encapsulation)
115
127
 *  OVS_KEY_ATTR_ETHERTYPE               2     2     4      8  (inner VLAN ethertype)
116
128
 *  OVS_KEY_ATTR_IPV6                   40    --     4     44
117
129
 *  OVS_KEY_ATTR_ICMPV6                  2     2     4      8
118
130
 *  OVS_KEY_ATTR_ND                     28    --     4     32
119
131
 *  ----------------------------------------------------------
120
 
 *  total                                                 208
 
132
 *  total                                                 488
121
133
 *
122
134
 * We include some slack space in case the calculation isn't quite right or we
123
135
 * add another field and forget to adjust this value.
124
136
 */
125
 
#define ODPUTIL_FLOW_KEY_BYTES 256
 
137
#define ODPUTIL_FLOW_KEY_BYTES 512
 
138
BUILD_ASSERT_DECL(FLOW_WC_SEQ == 31);
126
139
 
127
140
/* A buffer with sufficient size and alignment to hold an nlattr-formatted flow
128
141
 * key.  An array of "struct nlattr" might not, in theory, be sufficiently
134
147
enum odp_key_fitness odp_tun_key_from_attr(const struct nlattr *,
135
148
                                           struct flow_tnl *);
136
149
 
 
150
int odp_ufid_from_string(const char *s_, ovs_u128 *ufid);
 
151
void odp_format_ufid(const ovs_u128 *ufid, struct ds *);
137
152
void odp_flow_format(const struct nlattr *key, size_t key_len,
138
153
                     const struct nlattr *mask, size_t mask_len,
139
154
                     const struct hmap *portno_names, struct ds *,
144
159
                         struct ofpbuf *, struct ofpbuf *);
145
160
 
146
161
void odp_flow_key_from_flow(struct ofpbuf *, const struct flow * flow,
147
 
                            const struct flow *mask, odp_port_t odp_in_port);
 
162
                            const struct flow *mask, odp_port_t odp_in_port,
 
163
                            bool recirc);
148
164
void odp_flow_key_from_mask(struct ofpbuf *, const struct flow *mask,
149
165
                            const struct flow *flow, uint32_t odp_in_port,
150
 
                            size_t max_mpls_depth);
 
166
                            size_t max_mpls_depth, bool recirc);
151
167
 
152
168
uint32_t odp_flow_key_hash(const struct nlattr *, size_t);
153
169
 
179
195
 
180
196
void commit_odp_tunnel_action(const struct flow *, struct flow *base,
181
197
                              struct ofpbuf *odp_actions);
 
198
void commit_masked_set_action(struct ofpbuf *odp_actions,
 
199
                              enum ovs_key_attr key_type, const void *key,
 
200
                              const void *mask, size_t key_size);
182
201
enum slow_path_reason commit_odp_actions(const struct flow *,
183
202
                                         struct flow *base,
184
203
                                         struct ofpbuf *odp_actions,
185
 
                                         struct flow_wildcards *wc);
 
204
                                         struct flow_wildcards *wc,
 
205
                                         bool use_masked);
186
206
 
187
207
/* ofproto-dpif interface.
188
208
 *
225
245
    } flow_sample;
226
246
 
227
247
    struct {
228
 
        uint16_t type;          /* USER_ACTION_COOKIE_IPFIX. */
 
248
        uint16_t   type;            /* USER_ACTION_COOKIE_IPFIX. */
 
249
        odp_port_t output_odp_port; /* The output odp port. */
229
250
    } ipfix;
230
251
};
231
252
BUILD_ASSERT_DECL(sizeof(union user_action_cookie) == 16);
232
253
 
233
254
size_t odp_put_userspace_action(uint32_t pid,
234
255
                                const void *userdata, size_t userdata_size,
 
256
                                odp_port_t tunnel_out_port,
235
257
                                struct ofpbuf *odp_actions);
236
258
void odp_put_tunnel_action(const struct flow_tnl *tunnel,
237
259
                           struct ofpbuf *odp_actions);
238
 
void odp_put_pkt_mark_action(const uint32_t pkt_mark,
239
 
                             struct ofpbuf *odp_actions);
240
260
 
 
261
void odp_put_tnl_push_action(struct ofpbuf *odp_actions,
 
262
                             struct ovs_action_push_tnl *data);
241
263
#endif /* odp-util.h */