]> git.proxmox.com Git - ovs.git/blame - ovn/lib/actions.h
expr: Refactor parsing of assignments and exchanges.
[ovs.git] / ovn / lib / actions.h
CommitLineData
3b7cb7e1 1/*
6335d074 2 * Copyright (c) 2015, 2016 Nicira, Inc.
3b7cb7e1
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 OVN_ACTIONS_H
18#define OVN_ACTIONS_H 1
19
f1c16a85 20#include <stdbool.h>
3b7cb7e1
BP
21#include <stdint.h>
22#include "compiler.h"
6335d074 23#include "util.h"
3b7cb7e1
BP
24
25struct expr;
26struct lexer;
27struct ofpbuf;
28struct shash;
29struct simap;
30
6335d074
BP
31enum action_opcode {
32 /* "arp { ...actions... }".
33 *
34 * The actions, in OpenFlow 1.3 format, follow the action_header.
35 */
36 ACTION_OPCODE_ARP,
0bac7164
BP
37
38 /* "put_arp(port, ip, mac)"
39 *
40 * Arguments are passed through the packet metadata and data, as follows:
41 *
42 * MFF_REG0 = ip
43 * MFF_LOG_INPORT = port
44 * MFF_ETH_SRC = mac
45 */
46 ACTION_OPCODE_PUT_ARP,
6335d074
BP
47};
48
49/* Header. */
50struct action_header {
51 ovs_be32 opcode; /* One of ACTION_OPCODE_* */
52 uint8_t pad[4];
53};
54BUILD_ASSERT_DECL(sizeof(struct action_header) == 8);
55
1d7b2ece
BP
56struct action_params {
57 /* A table of "struct expr_symbol"s to support (as one would provide to
58 * expr_parse()). */
59 const struct shash *symtab;
60
f1c16a85
BP
61 /* Looks up logical port 'port_name'. If found, stores its port number in
62 * '*portp' and returns true; otherwise, returns false. */
63 bool (*lookup_port)(const void *aux, const char *port_name,
64 unsigned int *portp);
65 const void *aux;
1d7b2ece
BP
66
67 /* A map from a port name to its connection tracking zone. */
68 const struct simap *ct_zones;
69
70 /* OVN maps each logical flow table (ltable), one-to-one, onto a physical
71 * OpenFlow flow table (ptable). A number of parameters describe this
72 * mapping and data related to flow tables:
73 *
74 * - 'first_ptable' and 'n_tables' define the range of OpenFlow tables
75 * to which the logical "next" action should be able to jump.
76 * Logical table 0 maps to OpenFlow table 'first_ptable', logical
77 * table 1 to 'first_ptable + 1', and so on. If 'n_tables' is 0
78 * then "next" is disallowed entirely.
79 *
80 * - 'cur_ltable' is an offset from 'first_ptable' (e.g. 0 <=
81 * cur_ltable < n_ptables) of the logical flow that contains the
82 * actions. If cur_ltable + 1 < n_tables, then this defines the
83 * default table that "next" will jump to.
84 *
85 * - 'output_ptable' should be the OpenFlow table to which the logical
86 * "output" action will resubmit. */
87 uint8_t n_tables; /* Number of flow tables. */
88 uint8_t first_ptable; /* First OpenFlow table. */
89 uint8_t cur_ltable; /* 0 <= cur_ltable < n_tables. */
90 uint8_t output_ptable; /* OpenFlow table for 'output' to resubmit. */
0bac7164 91 uint8_t arp_ptable; /* OpenFlow table for 'get_arp' to resubmit. */
1d7b2ece
BP
92};
93
94char *actions_parse(struct lexer *, const struct action_params *,
95 struct ofpbuf *ofpacts, struct expr **prereqsp)
ea53e3a8 96 OVS_WARN_UNUSED_RESULT;
1d7b2ece
BP
97char *actions_parse_string(const char *s, const struct action_params *,
98 struct ofpbuf *ofpacts, struct expr **prereqsp)
ea53e3a8 99 OVS_WARN_UNUSED_RESULT;
3b7cb7e1
BP
100
101#endif /* ovn/actions.h */