else:
output += [" -1, /* not usable for prefix lookup */"]
- output += [" {OVSRCU_INITIALIZER(NULL)},},"]
+ output += ["},"]
for oline in output:
print(oline)
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
-#include "cmap.h"
#include "openvswitch/flow.h"
#include "openvswitch/ofp-errors.h"
#include "openvswitch/packets.h"
-#include "openvswitch/thread.h"
#include "openvswitch/util.h"
struct ds;
int flow_be32ofs; /* Field's be32 offset in "struct flow", if prefix tree
* lookup is supported for the field, or -1. */
-
- /* For variable length mf_fields only. In ofproto->vl_mff_map->cmap. */
- struct cmap_node cmap_node;
};
/* The representation of a field's value. */
};
BUILD_ASSERT_DECL(sizeof(union mf_value) == sizeof (union mf_subvalue));
-/* Variable length mf_fields mapping map. This is a single writer,
- * multiple-reader hash table that a writer must hold the following mutex
- * to access this map. */
-struct vl_mff_map {
- struct cmap cmap; /* Contains 'struct mf_field' */
- struct ovs_mutex mutex;
-};
-
bool mf_subvalue_intersect(const union mf_subvalue *a_value,
const union mf_subvalue *a_mask,
const union mf_subvalue *b_value,
/* Field Arrays. */
void field_array_set(enum mf_field_id id, const union mf_value *,
struct field_array *);
-
-/* Variable length fields. */
-void mf_vl_mff_map_clear(struct vl_mff_map *vl_mff_map)
- OVS_REQUIRES(vl_mff_map->mutex);
-enum ofperr mf_vl_mff_map_mod_from_tun_metadata(
- struct vl_mff_map *vl_mff_map, const struct ofputil_tlv_table_mod *)
- OVS_REQUIRES(vl_mff_map->mutex);
-const struct mf_field * mf_get_vl_mff(const struct mf_field *,
- const struct vl_mff_map *);
-bool mf_vl_mff_invalid(const struct mf_field *, const struct vl_mff_map *);
#endif /* meta-flow.h */
#include "openvswitch/ofp-errors.h"
#include "openvswitch/types.h"
+struct vl_mff_map;
+
/* List of OVS abstracted actions.
*
* This macro is used directly only internally by this header, but the list is
struct ofpbuf;
union ofp_action;
struct ofpact_set_field;
+struct vl_mff_map;
/* Port numbers. */
enum ofperr ofputil_port_from_ofp11(ovs_be32 ofp11_port,
lib/vconn-stream.c \
lib/vconn.c \
lib/versions.h \
+ lib/vl-mff-map.h \
lib/vlan-bitmap.c \
lib/vlan-bitmap.h \
lib/vlog.c \
#include "util.h"
#include "openvswitch/ofp-errors.h"
#include "openvswitch/vlog.h"
+#include "vl-mff-map.h"
VLOG_DEFINE_THIS_MODULE(meta_flow);
memcpy(fa->values + offset, value, value_size);
}
+/* A wrapper for variable length mf_fields that is maintained by
+ * struct vl_mff_map.*/
+struct vl_mf_field {
+ struct mf_field mf;
+ struct cmap_node cmap_node; /* In ofproto->vl_mff_map->cmap. */
+};
+
static inline uint32_t
mf_field_hash(uint32_t key)
{
mf_vl_mff_map_clear(struct vl_mff_map *vl_mff_map)
OVS_REQUIRES(vl_mff_map->mutex)
{
- struct mf_field *mf;
+ struct vl_mf_field *vmf;
- CMAP_FOR_EACH (mf, cmap_node, &vl_mff_map->cmap) {
- cmap_remove(&vl_mff_map->cmap, &mf->cmap_node, mf_field_hash(mf->id));
- ovsrcu_postpone(free, mf);
+ CMAP_FOR_EACH (vmf, cmap_node, &vl_mff_map->cmap) {
+ cmap_remove(&vl_mff_map->cmap, &vmf->cmap_node,
+ mf_field_hash(vmf->mf.id));
+ ovsrcu_postpone(free, vmf);
}
}
-static struct mf_field *
+static struct vl_mf_field *
mf_get_vl_mff__(uint32_t id, const struct vl_mff_map *vl_mff_map)
{
- struct mf_field *field;
+ struct vl_mf_field *vmf;
- CMAP_FOR_EACH_WITH_HASH (field, cmap_node, mf_field_hash(id),
+ CMAP_FOR_EACH_WITH_HASH (vmf, cmap_node, mf_field_hash(id),
&vl_mff_map->cmap) {
- if (field->id == id) {
- return field;
+ if (vmf->mf.id == id) {
+ return vmf;
}
}
const struct vl_mff_map *vl_mff_map)
{
if (mff && mff->variable_len && vl_mff_map) {
- return mf_get_vl_mff__(mff->id, vl_mff_map);
+ return &mf_get_vl_mff__(mff->id, vl_mff_map)->mf;
}
return NULL;
LIST_FOR_EACH (tlv_map, list_node, &ttm->mappings) {
unsigned int idx = MFF_TUN_METADATA0 + tlv_map->index;
- struct mf_field *mf;
+ struct vl_mf_field *vmf;
if (idx >= MFF_TUN_METADATA0 + TUN_METADATA_NUM_OPTS) {
return OFPERR_NXTTMFC_BAD_FIELD_IDX;
switch (ttm->command) {
case NXTTMC_ADD:
- mf = xmalloc(sizeof *mf);
- *mf = mf_fields[idx];
- mf->n_bytes = tlv_map->option_len;
- mf->n_bits = tlv_map->option_len * 8;
- mf->mapped = true;
-
- cmap_insert(&vl_mff_map->cmap, &mf->cmap_node, mf_field_hash(idx));
+ vmf = xmalloc(sizeof *vmf);
+ vmf->mf = mf_fields[idx];
+ vmf->mf.n_bytes = tlv_map->option_len;
+ vmf->mf.n_bits = tlv_map->option_len * 8;
+ vmf->mf.mapped = true;
+
+ cmap_insert(&vl_mff_map->cmap, &vmf->cmap_node,
+ mf_field_hash(idx));
break;
case NXTTMC_DELETE:
- mf = mf_get_vl_mff__(idx, vl_mff_map);
- if (mf) {
- cmap_remove(&vl_mff_map->cmap, &mf->cmap_node,
+ vmf = mf_get_vl_mff__(idx, vl_mff_map);
+ if (vmf) {
+ cmap_remove(&vl_mff_map->cmap, &vmf->cmap_node,
mf_field_hash(idx));
- ovsrcu_postpone(free, mf);
+ ovsrcu_postpone(free, vmf);
}
break;
#include "tun-metadata.h"
#include "unaligned.h"
#include "util.h"
+#include "vl-mff-map.h"
VLOG_DEFINE_THIS_MODULE(nx_match);
struct ofpbuf;
struct nx_action_reg_load;
struct nx_action_reg_move;
+struct vl_mff_map;
/* Nicira Extended Match (NXM) flexible flow match helper functions.
#include "openvswitch/vlog.h"
#include "unaligned.h"
#include "util.h"
+#include "vl-mff-map.h"
VLOG_DEFINE_THIS_MODULE(ofp_actions);
--- /dev/null
+/*
+ * Copyright (c) 2017 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 VL_MFF_MAP_H
+#define VL_MFF_MAP_H 1
+
+#include "cmap.h"
+#include "openvswitch/thread.h"
+
+/* Variable length mf_fields mapping map. This is a single writer,
+ * multiple-reader hash table that a writer must hold the following mutex
+ * to access this map. */
+struct vl_mff_map {
+ struct cmap cmap; /* Contains 'struct mf_field' */
+ struct ovs_mutex mutex;
+};
+
+/* Variable length fields. */
+void mf_vl_mff_map_clear(struct vl_mff_map *vl_mff_map)
+ OVS_REQUIRES(vl_mff_map->mutex);
+enum ofperr mf_vl_mff_map_mod_from_tun_metadata(
+ struct vl_mff_map *vl_mff_map, const struct ofputil_tlv_table_mod *)
+ OVS_REQUIRES(vl_mff_map->mutex);
+const struct mf_field * mf_get_vl_mff(const struct mf_field *,
+ const struct vl_mff_map *);
+bool mf_vl_mff_invalid(const struct mf_field *, const struct vl_mff_map *);
+
+#endif /* vl-mff-map.h */
#include "timeval.h"
#include "tun-metadata.h"
#include "versions.h"
+#include "vl-mff-map.h"
struct match;
struct ofputil_flow_mod;
struct meter;
struct ofoperation;
struct ofproto_packet_out;
-struct vl_mff_map;
struct smap;
extern struct ovs_mutex ofproto_mutex;