diff options
author | Ethan Jackson <ethan@nicira.com> | 2013-06-20 13:00:27 -0700 |
---|---|---|
committer | Ethan Jackson <ethan@nicira.com> | 2013-07-07 03:58:47 -0700 |
commit | ec7ceaed4f3e03a3e59056a3a82a08886c328ce8 (patch) | |
tree | 93694925d2c04574007e1474b3a985397c4bedcb /ofproto/ofproto-dpif-mirror.h | |
parent | cdf5d3a51e9ccd33ef77b5dcd9b03671f3352650 (diff) | |
download | openvswitch-ec7ceaed4f3e03a3e59056a3a82a08886c328ce8.tar.gz |
ofproto-dpif: Modularize mirror code.
This code modularizes ofproto-dpif's mirror code by moving it to
ofproto-dpif-mirror. Not only does this shorten ofproto-dpif and
hide complexity, but its also necessary for future patches which
modularize ofproto-dpif-xlate in preparation for multi-threading.
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'ofproto/ofproto-dpif-mirror.h')
-rw-r--r-- | ofproto/ofproto-dpif-mirror.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/ofproto/ofproto-dpif-mirror.h b/ofproto/ofproto-dpif-mirror.h new file mode 100644 index 000000000..4a6f3cebd --- /dev/null +++ b/ofproto/ofproto-dpif-mirror.h @@ -0,0 +1,61 @@ +/* Copyright (c) 2013 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 OFPROT_DPIF_MIRROR_H +#define OFPROT_DPIF_MIRROR_H 1 + +#include <stdint.h> + +#include "util.h" + +#define MAX_MIRRORS 32 +typedef uint32_t mirror_mask_t; + +struct ofproto_dpif; +struct ofbundle; + +struct mbridge *mbridge_create(void); +struct mbridge *mbridge_ref(const struct mbridge *); +void mbridge_unref(struct mbridge *); +bool mbridge_has_mirrors(struct mbridge *); +bool mbridge_need_revalidate(struct mbridge *); + +void mbridge_register_bundle(struct mbridge *, struct ofbundle *); +void mbridge_unregister_bundle(struct mbridge *, struct ofbundle *); + +mirror_mask_t mirror_bundle_out(struct mbridge *, struct ofbundle *); +mirror_mask_t mirror_bundle_src(struct mbridge *, struct ofbundle *); +mirror_mask_t mirror_bundle_dst(struct mbridge *, struct ofbundle *); + +int mirror_set(struct mbridge *, void *aux, const char *name, + struct ofbundle **srcs, size_t n_srcs, + struct ofbundle **dsts, size_t n_dsts, + unsigned long *src_vlans, struct ofbundle *out_bundle, + uint16_t out_vlan); +void mirror_destroy(struct mbridge *, void *aux); +int mirror_get_stats(struct mbridge *, void *aux, uint64_t *packets, + uint64_t *bytes); +void mirror_update_stats(struct mbridge*, mirror_mask_t, uint64_t packets, + uint64_t bytes); +bool mirror_get(struct mbridge *, int index, unsigned long **vlans, + mirror_mask_t *dup_mirrors, struct ofbundle **out, + int *out_vlan); + +static inline int +mirror_mask_ffs(mirror_mask_t mask) +{ + BUILD_ASSERT_DECL(sizeof(unsigned int) >= sizeof(mask)); + return ffs(mask); +} +#endif /* ofproto-dpif-mirror.h */ |