]> git.proxmox.com Git - mirror_ovs.git/blame - lib/nx-match.h
bridge: Relax the whitelist format for punix path.
[mirror_ovs.git] / lib / nx-match.h
CommitLineData
09246b99 1/*
b71273f6 2 * Copyright (c) 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
09246b99
BP
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 NX_MATCH_H
18#define NX_MATCH_H 1
19
20#include <stdint.h>
c979df05
BP
21#include <sys/types.h>
22#include <netinet/in.h>
bdda5aca 23#include "compiler.h"
e9358af6 24#include "flow.h"
178742f9 25#include "meta-flow.h"
f25d0cf3 26#include "ofp-errors.h"
c979df05 27#include "openvswitch/types.h"
09246b99 28
f393f81e 29struct ds;
81a76618 30struct match;
f25d0cf3
BP
31struct ofpact_reg_move;
32struct ofpact_reg_load;
bd85dac1 33struct ofpact_stack;
09246b99 34struct ofpbuf;
b6c9e612
BP
35struct nx_action_reg_load;
36struct nx_action_reg_move;
09246b99 37
bd85dac1 38
09246b99
BP
39/* Nicira Extended Match (NXM) flexible flow match helper functions.
40 *
41 * See include/openflow/nicira-ext.h for NXM specification.
42 */
43
178742f9
BP
44void mf_format_subfield(const struct mf_subfield *, struct ds *);
45char *mf_parse_subfield__(struct mf_subfield *sf, const char **s)
cab50449 46 OVS_WARN_UNUSED_RESULT;
178742f9 47char *mf_parse_subfield(struct mf_subfield *, const char *s)
cab50449 48 OVS_WARN_UNUSED_RESULT;
178742f9 49
90bf1e07 50enum ofperr nx_pull_match(struct ofpbuf *, unsigned int match_len,
81a76618 51 struct match *,
90bf1e07
BP
52 ovs_be64 *cookie, ovs_be64 *cookie_mask);
53enum ofperr nx_pull_match_loose(struct ofpbuf *, unsigned int match_len,
81a76618 54 struct match *, ovs_be64 *cookie,
7623f4dd 55 ovs_be64 *cookie_mask);
81a76618
BP
56enum ofperr oxm_pull_match(struct ofpbuf *, struct match *);
57enum ofperr oxm_pull_match_loose(struct ofpbuf *, struct match *);
bc65c25a
SH
58enum ofperr oxm_pull_field_array(const void *, size_t fields_len,
59 struct field_array *);
81a76618 60int nx_put_match(struct ofpbuf *, const struct match *,
e729e793 61 ovs_be64 cookie, ovs_be64 cookie_mask);
9d84066c 62int oxm_put_match(struct ofpbuf *, const struct match *, enum ofp_version);
53eb84a5
SH
63void oxm_format_field_array(struct ds *, const struct field_array *);
64int oxm_put_field_array(struct ofpbuf *, const struct field_array *,
65 enum ofp_version version);
09246b99 66
178742f9
BP
67/* Decoding and encoding OXM/NXM headers (just a field ID) or entries (a field
68 * ID followed by a value and possibly a mask). */
69enum ofperr nx_pull_entry(struct ofpbuf *, const struct mf_field **,
70 union mf_value *value, union mf_value *mask);
71enum ofperr nx_pull_header(struct ofpbuf *, const struct mf_field **,
72 bool *masked);
9558d2a5
JG
73void nxm_put(struct ofpbuf *b, enum mf_field_id field,
74 enum ofp_version version, const void *value,
75 const void *mask, size_t n_bytes);
178742f9
BP
76void nx_put_entry(struct ofpbuf *, enum mf_field_id, enum ofp_version,
77 const union mf_value *value, const union mf_value *mask);
78void nx_put_header(struct ofpbuf *, enum mf_field_id, enum ofp_version,
79 bool masked);
80
81/* NXM and OXM protocol headers values.
82 *
83 * These are often alternatives to nx_pull_entry/header() and
84 * nx_put_entry/header() for decoding and encoding OXM/NXM. In those cases,
85 * the nx_*() functions should be preferred because they can support the 64-bit
86 * "experimenter" OXM format (even though it is not yet implemented). */
508a9338 87uint32_t mf_nxm_header(enum mf_field_id);
178742f9
BP
88const struct mf_field *mf_from_nxm_header(uint32_t nxm_header);
89
09246b99 90char *nx_match_to_string(const uint8_t *, unsigned int match_len);
db5a1019 91char *oxm_match_to_string(const struct ofpbuf *, unsigned int match_len);
09246b99 92int nx_match_from_string(const char *, struct ofpbuf *);
7623f4dd 93int oxm_match_from_string(const char *, struct ofpbuf *);
09246b99 94
178742f9
BP
95void nx_format_field_name(enum mf_field_id, enum ofp_version, struct ds *);
96
bdda5aca 97char *nxm_parse_reg_move(struct ofpact_reg_move *, const char *)
cab50449 98 OVS_WARN_UNUSED_RESULT;
f25d0cf3
BP
99
100void nxm_format_reg_move(const struct ofpact_reg_move *, struct ds *);
f393f81e 101
f25d0cf3 102enum ofperr nxm_reg_move_check(const struct ofpact_reg_move *,
816fd533 103 const struct flow *);
b6c9e612 104
bcd2633a
JP
105void nxm_execute_reg_move(const struct ofpact_reg_move *, struct flow *,
106 struct flow_wildcards *);
f25d0cf3 107void nxm_reg_load(const struct mf_subfield *, uint64_t src_data,
f74e7df7 108 struct flow *, struct flow_wildcards *);
b6c9e612 109
bdda5aca 110char *nxm_parse_stack_action(struct ofpact_stack *, const char *)
cab50449 111 OVS_WARN_UNUSED_RESULT;
bd85dac1
AZ
112
113void nxm_format_stack_push(const struct ofpact_stack *, struct ds *);
114void nxm_format_stack_pop(const struct ofpact_stack *, struct ds *);
115
bd85dac1
AZ
116enum ofperr nxm_stack_push_check(const struct ofpact_stack *,
117 const struct flow *);
118enum ofperr nxm_stack_pop_check(const struct ofpact_stack *,
119 const struct flow *);
120
bd85dac1 121void nxm_execute_stack_push(const struct ofpact_stack *,
bcd2633a
JP
122 const struct flow *, struct flow_wildcards *,
123 struct ofpbuf *);
bd85dac1 124void nxm_execute_stack_pop(const struct ofpact_stack *,
f74e7df7
JP
125 struct flow *, struct flow_wildcards *,
126 struct ofpbuf *);
bd85dac1 127
178742f9
BP
128ovs_be64 oxm_bitmap_from_mf_bitmap(const struct mf_bitmap *, enum ofp_version);
129struct mf_bitmap oxm_bitmap_to_mf_bitmap(ovs_be64 oxm_bitmap,
130 enum ofp_version);
131struct mf_bitmap oxm_writable_fields(void);
132struct mf_bitmap oxm_matchable_fields(void);
133struct mf_bitmap oxm_maskable_fields(void);
4291acd2 134
816fd533 135/* Dealing with the 'ofs_nbits' members in several Nicira extensions. */
c979df05
BP
136
137static inline ovs_be16
138nxm_encode_ofs_nbits(int ofs, int n_bits)
139{
140 return htons((ofs << 6) | (n_bits - 1));
141}
142
143static inline int
144nxm_decode_ofs(ovs_be16 ofs_nbits)
145{
146 return ntohs(ofs_nbits) >> 6;
147}
148
149static inline int
150nxm_decode_n_bits(ovs_be16 ofs_nbits)
151{
152 return (ntohs(ofs_nbits) & 0x3f) + 1;
153}
154\f
2e4f5fcf
BP
155/* This is my guess at the length of a "typical" nx_match, for use in
156 * predicting space requirements. */
157#define NXM_TYPICAL_LEN 64
158
09246b99 159#endif /* nx-match.h */