2016-09-14 16:51:27 -07:00
|
|
|
/* Copyright (c) 2016 Nicira, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at:
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License. */
|
|
|
|
|
|
|
|
#ifndef OFPROTO_DPIF_XLATE_CACHE_H
|
|
|
|
#define OFPROTO_DPIF_XLATE_CACHE_H 1
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#include "openvswitch/types.h"
|
|
|
|
#include "dp-packet.h"
|
|
|
|
#include "odp-util.h"
|
|
|
|
#include "ofproto/ofproto-dpif-mirror.h"
|
|
|
|
#include "openvswitch/ofpbuf.h"
|
|
|
|
|
|
|
|
struct bfd;
|
|
|
|
struct bond;
|
|
|
|
struct dpif_flow_stats;
|
|
|
|
struct flow;
|
|
|
|
struct group_dpif;
|
|
|
|
struct mbridge;
|
|
|
|
struct netdev;
|
|
|
|
struct netflow;
|
|
|
|
struct ofpbuf;
|
|
|
|
struct ofproto_dpif;
|
|
|
|
struct ofputil_bucket;
|
|
|
|
struct ofputil_flow_mod;
|
|
|
|
struct rule_dpif;
|
|
|
|
|
|
|
|
enum xc_type {
|
2016-09-14 16:51:27 -07:00
|
|
|
XC_TABLE,
|
2016-09-14 16:51:27 -07:00
|
|
|
XC_RULE,
|
|
|
|
XC_BOND,
|
|
|
|
XC_NETDEV,
|
|
|
|
XC_NETFLOW,
|
|
|
|
XC_MIRROR,
|
2016-09-14 16:51:27 -07:00
|
|
|
XC_LEARN, /* Calls back to ofproto. */
|
2016-09-14 16:51:27 -07:00
|
|
|
XC_NORMAL,
|
2016-09-14 16:51:27 -07:00
|
|
|
XC_FIN_TIMEOUT, /* Calls back to ofproto. */
|
2016-09-14 16:51:27 -07:00
|
|
|
XC_GROUP,
|
|
|
|
XC_TNL_NEIGH,
|
2016-09-14 16:51:27 -07:00
|
|
|
XC_CONTROLLER,
|
2017-07-19 14:46:03 +01:00
|
|
|
XC_TUNNEL_HEADER,
|
2016-09-14 16:51:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* xlate_cache entries hold enough information to perform the side effects of
|
|
|
|
* xlate_actions() for a rule, without needing to perform rule translation
|
|
|
|
* from scratch. The primary usage of these is to submit statistics to objects
|
|
|
|
* that a flow relates to, although they may be used for other effects as well
|
|
|
|
* (for instance, refreshing hard timeouts for learned flows).
|
|
|
|
*
|
|
|
|
* An explicit reference is taken to all pointers other than the ones for
|
|
|
|
* struct ofproto_dpif. ofproto_dpif pointers are explicitly protected by
|
|
|
|
* destroying all xlate caches before the ofproto is destroyed. */
|
|
|
|
struct xc_entry {
|
|
|
|
enum xc_type type;
|
|
|
|
union {
|
2016-09-14 16:51:27 -07:00
|
|
|
struct {
|
|
|
|
struct ofproto_dpif *ofproto;
|
|
|
|
uint8_t id;
|
|
|
|
bool match; /* or miss. */
|
|
|
|
} table;
|
2016-09-14 16:51:27 -07:00
|
|
|
struct rule_dpif *rule;
|
|
|
|
struct {
|
|
|
|
struct netdev *tx;
|
|
|
|
struct netdev *rx;
|
|
|
|
struct bfd *bfd;
|
|
|
|
} dev;
|
|
|
|
struct {
|
|
|
|
struct netflow *netflow;
|
|
|
|
struct flow *flow;
|
|
|
|
ofp_port_t iface;
|
|
|
|
} nf;
|
|
|
|
struct {
|
|
|
|
struct mbridge *mbridge;
|
|
|
|
mirror_mask_t mirrors;
|
|
|
|
} mirror;
|
|
|
|
struct {
|
|
|
|
struct bond *bond;
|
|
|
|
struct flow *flow;
|
|
|
|
uint16_t vid;
|
|
|
|
} bond;
|
|
|
|
struct {
|
2016-09-14 16:51:27 -07:00
|
|
|
struct ofproto_flow_mod *ofm;
|
2017-03-10 15:44:40 -08:00
|
|
|
unsigned limit;
|
2016-09-14 16:51:27 -07:00
|
|
|
} learn;
|
|
|
|
struct {
|
|
|
|
struct ofproto_dpif *ofproto;
|
|
|
|
ofp_port_t in_port;
|
|
|
|
struct eth_addr dl_src;
|
|
|
|
int vlan;
|
|
|
|
bool is_gratuitous_arp;
|
|
|
|
} normal;
|
|
|
|
struct {
|
|
|
|
struct rule_dpif *rule;
|
|
|
|
uint16_t idle;
|
|
|
|
uint16_t hard;
|
|
|
|
} fin;
|
|
|
|
struct {
|
|
|
|
struct group_dpif *group;
|
|
|
|
struct ofputil_bucket *bucket;
|
|
|
|
} group;
|
|
|
|
struct {
|
|
|
|
char br_name[IFNAMSIZ];
|
|
|
|
struct in6_addr d_ipv6;
|
|
|
|
} tnl_neigh_cache;
|
2016-09-14 16:51:27 -07:00
|
|
|
struct {
|
|
|
|
struct ofproto_dpif *ofproto;
|
|
|
|
struct ofproto_async_msg *am;
|
|
|
|
} controller;
|
2017-07-19 14:46:03 +01:00
|
|
|
struct {
|
|
|
|
enum {
|
|
|
|
ADD,
|
|
|
|
REMOVE,
|
|
|
|
} operation;
|
|
|
|
uint16_t hdr_size;
|
|
|
|
} tunnel_hdr;
|
2016-09-14 16:51:27 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#define XC_ENTRY_FOR_EACH(ENTRY, ENTRIES) \
|
|
|
|
for (ENTRY = ofpbuf_try_pull(ENTRIES, sizeof *ENTRY); \
|
|
|
|
ENTRY; \
|
|
|
|
ENTRY = ofpbuf_try_pull(ENTRIES, sizeof *ENTRY))
|
|
|
|
|
|
|
|
struct xlate_cache {
|
|
|
|
struct ofpbuf entries;
|
|
|
|
};
|
|
|
|
|
2016-09-14 16:51:27 -07:00
|
|
|
void xlate_cache_init(struct xlate_cache *);
|
2016-09-14 16:51:27 -07:00
|
|
|
struct xlate_cache *xlate_cache_new(void);
|
|
|
|
struct xc_entry *xlate_cache_add_entry(struct xlate_cache *, enum xc_type);
|
2017-07-19 14:46:03 +01:00
|
|
|
void xlate_push_stats_entry(struct xc_entry *, struct dpif_flow_stats *);
|
|
|
|
void xlate_push_stats(struct xlate_cache *, struct dpif_flow_stats *);
|
2016-09-14 16:51:27 -07:00
|
|
|
void xlate_cache_clear_entry(struct xc_entry *);
|
|
|
|
void xlate_cache_clear(struct xlate_cache *);
|
2016-09-14 16:51:27 -07:00
|
|
|
void xlate_cache_uninit(struct xlate_cache *);
|
2016-09-14 16:51:27 -07:00
|
|
|
void xlate_cache_delete(struct xlate_cache *);
|
2017-07-19 14:46:03 +01:00
|
|
|
void xlate_cache_steal_entries(struct xlate_cache *, struct xlate_cache *);
|
2016-09-14 16:51:27 -07:00
|
|
|
|
|
|
|
#endif /* ofproto-dpif-xlate-cache.h */
|