blob: d4cf27329eaaf871f98abb589fad96c707fb82da [file] [log] [blame]
Rich Lanea06d0c32013-03-25 08:52:03 -07001# Copyright 2013, Big Switch Networks, Inc.
2#
3# LoxiGen is licensed under the Eclipse Public License, version 1.0 (EPL), with
4# the following special exception:
5#
6# LOXI Exception
7#
8# As a special exception to the terms of the EPL, you may distribute libraries
9# generated by LoxiGen (LoxiGen Libraries) under the terms of your choice, provided
10# that copyright and licensing notices generated by LoxiGen are not altered or removed
11# from the LoxiGen Libraries and the notice provided below is (i) included in
12# the LoxiGen Libraries, if distributed in source code form and (ii) included in any
13# documentation for the LoxiGen Libraries, if distributed in binary form.
14#
15# Notice: "Copyright 2013, Big Switch Networks, Inc. This library was generated by the LoxiGen Compiler."
16#
17# You may not use this file except in compliance with the EPL or LOXI Exception. You may obtain
18# a copy of the EPL at:
19#
20# http://www.eclipse.org/legal/epl-v10.html
21#
22# Unless required by applicable law or agreed to in writing, software
23# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
25# EPL for the specific language governing permissions and limitations
26# under the EPL.
27
28import of_g
29
30oxm_types = dict(
31 in_port = "of_port_no_t",
32 in_port_masked = "of_port_no_t",
33 in_phy_port = "of_port_no_t",
34 in_phy_port_masked = "of_port_no_t",
35 metadata = "uint64_t",
36 metadata_masked = "uint64_t",
37 eth_dst = "of_mac_addr_t",
38 eth_dst_masked = "of_mac_addr_t",
39 eth_src = "of_mac_addr_t",
40 eth_src_masked = "of_mac_addr_t",
41 eth_type = "uint16_t",
42 eth_type_masked = "uint16_t",
43 vlan_vid = "uint16_t",
44 vlan_vid_masked = "uint16_t",
45 vlan_pcp = "uint8_t",
46 vlan_pcp_masked = "uint8_t",
47 ip_dscp = "uint8_t",
48 ip_dscp_masked = "uint8_t",
49 ip_ecn = "uint8_t",
50 ip_ecn_masked = "uint8_t",
51 ip_proto = "uint8_t",
52 ip_proto_masked = "uint8_t",
53 ipv4_src = "uint32_t",
54 ipv4_src_masked = "uint32_t",
55 ipv4_dst = "uint32_t",
56 ipv4_dst_masked = "uint32_t",
57 tcp_src = "uint16_t",
58 tcp_src_masked = "uint16_t",
59 tcp_dst = "uint16_t",
60 tcp_dst_masked = "uint16_t",
61 udp_src = "uint16_t",
62 udp_src_masked = "uint16_t",
63 udp_dst = "uint16_t",
64 udp_dst_masked = "uint16_t",
65 sctp_src = "uint16_t",
66 sctp_src_masked = "uint16_t",
67 sctp_dst = "uint16_t",
68 sctp_dst_masked = "uint16_t",
69 icmpv4_type = "uint8_t",
70 icmpv4_type_masked = "uint8_t",
71 icmpv4_code = "uint8_t",
72 icmpv4_code_masked = "uint8_t",
73 arp_op = "uint16_t",
74 arp_op_masked = "uint16_t",
75 arp_spa = "uint32_t",
76 arp_spa_masked = "uint32_t",
77 arp_tpa = "uint32_t",
78 arp_tpa_masked = "uint32_t",
79 arp_sha = "of_mac_addr_t",
80 arp_sha_masked = "of_mac_addr_t",
81 arp_tha = "of_mac_addr_t",
82 arp_tha_masked = "of_mac_addr_t",
83 ipv6_src = "of_ipv6_t",
84 ipv6_src_masked = "of_ipv6_t",
85 ipv6_dst = "of_ipv6_t",
86 ipv6_dst_masked = "of_ipv6_t",
87 ipv6_flabel = "uint32_t",
88 ipv6_flabel_masked = "uint32_t",
89 icmpv6_type = "uint8_t",
90 icmpv6_type_masked = "uint8_t",
91 icmpv6_code = "uint8_t",
92 icmpv6_code_masked = "uint8_t",
93 ipv6_nd_target = "of_ipv6_t",
94 ipv6_nd_target_masked = "of_ipv6_t",
95 ipv6_nd_sll = "of_mac_addr_t",
96 ipv6_nd_sll_masked = "of_mac_addr_t",
97 ipv6_nd_tll = "of_mac_addr_t",
98 ipv6_nd_tll_masked = "of_mac_addr_t",
99 mpls_label = "uint32_t",
100 mpls_label_masked = "uint32_t",
101 mpls_tc = "uint8_t",
102 mpls_tc_masked = "uint8_t"
103 # FIXME Add 1.3 oxm elts
104 )
105
106oxm_wire_type = dict(
107 in_port = (0 << 1),
108 in_port_masked = (0 << 1) + 1,
109 in_phy_port = (1 << 1),
110 in_phy_port_masked = (1 << 1) + 1,
111 metadata = (2 << 1),
112 metadata_masked = (2 << 1) + 1,
113 eth_dst = (3 << 1),
114 eth_dst_masked = (3 << 1) + 1,
115 eth_src = (4 << 1),
116 eth_src_masked = (4 << 1) + 1,
117 eth_type = (5 << 1),
118 eth_type_masked = (5 << 1) + 1,
119 vlan_vid = (6 << 1),
120 vlan_vid_masked = (6 << 1) + 1,
121 vlan_pcp = (7 << 1),
122 vlan_pcp_masked = (7 << 1) + 1,
123 ip_dscp = (8 << 1),
124 ip_dscp_masked = (8 << 1) + 1,
125 ip_ecn = (9 << 1),
126 ip_ecn_masked = (9 << 1) + 1,
127 ip_proto = (10 << 1),
128 ip_proto_masked = (10 << 1) + 1,
129 ipv4_src = (11 << 1),
130 ipv4_src_masked = (11 << 1) + 1,
131 ipv4_dst = (12 << 1),
132 ipv4_dst_masked = (12 << 1) + 1,
133 tcp_src = (13 << 1),
134 tcp_src_masked = (13 << 1) + 1,
135 tcp_dst = (14 << 1),
136 tcp_dst_masked = (14 << 1) + 1,
137 udp_src = (15 << 1),
138 udp_src_masked = (15 << 1) + 1,
139 udp_dst = (16 << 1),
140 udp_dst_masked = (16 << 1) + 1,
141 sctp_src = (17 << 1),
142 sctp_src_masked = (17 << 1) + 1,
143 sctp_dst = (18 << 1),
144 sctp_dst_masked = (18 << 1) + 1,
145 icmpv4_type = (19 << 1),
146 icmpv4_type_masked = (19 << 1) + 1,
147 icmpv4_code = (20 << 1),
148 icmpv4_code_masked = (20 << 1) + 1,
149 arp_op = (21 << 1),
150 arp_op_masked = (21 << 1) + 1,
151 arp_spa = (22 << 1),
152 arp_spa_masked = (22 << 1) + 1,
153 arp_tpa = (23 << 1),
154 arp_tpa_masked = (23 << 1) + 1,
155 arp_sha = (24 << 1),
156 arp_sha_masked = (24 << 1) + 1,
157 arp_tha = (25 << 1),
158 arp_tha_masked = (25 << 1) + 1,
159 ipv6_src = (26 << 1),
160 ipv6_src_masked = (26 << 1) + 1,
161 ipv6_dst = (27 << 1),
162 ipv6_dst_masked = (27 << 1) + 1,
163 ipv6_flabel = (28 << 1),
164 ipv6_flabel_masked = (28 << 1) + 1,
165 icmpv6_type = (29 << 1),
166 icmpv6_type_masked = (29 << 1) + 1,
167 icmpv6_code = (30 << 1),
168 icmpv6_code_masked = (30 << 1) + 1,
169 ipv6_nd_target = (31 << 1),
170 ipv6_nd_target_masked = (31 << 1) + 1,
171 ipv6_nd_sll = (32 << 1),
172 ipv6_nd_sll_masked = (32 << 1) + 1,
173 ipv6_nd_tll = (33 << 1),
174 ipv6_nd_tll_masked = (33 << 1) + 1,
175 mpls_label = (34 << 1),
176 mpls_label_masked = (34 << 1) + 1,
177 mpls_tc = (35 << 1),
178 mpls_tc_masked = (35 << 1) + 1
179 # FIXME Add 1.3 oxm elts
180)
181
182def add_oxm_classes_1_2(classes, version):
183 """
184 Add the OXM classes to object passed. This is a dictionary
185 indexed by class name whose value is an array of member objects.
186 """
187 # First the parent class:
188 if version not in [of_g.VERSION_1_2, of_g.VERSION_1_3]:
189 return
190
191 members = []
192 classes["of_oxm"] = []
193 of_g.ordered_classes[version].append("of_oxm")
194 members.append(dict(name="type_len", m_type="uint32_t"))
195 classes["of_oxm_header"] = members
196 of_g.ordered_classes[version].append("of_oxm_header")
197
198 for oxm in oxm_types:
199 members = []
200 # Assert oxm_types[oxm] in of_base_types
201 m_type = oxm_types[oxm]
202 if m_type in of_g.of_mixed_types:
203 m_type = of_g.of_mixed_types[m_type][version]
204 # m_name = "value_" + of_g.of_base_types[m_type]["short_name"]
205 members.append(dict(name="type_len", m_type="uint32_t"))
206 # members.append(dict(name=m_name, m_type=oxm_types[oxm]))
207 members.append(dict(name="value", m_type=oxm_types[oxm]))
208 if oxm.find("_masked") > 0:
209 members.append(dict(name="value_mask", m_type=oxm_types[oxm]))
210
211 name = "of_oxm_" + oxm
212 of_g.ordered_classes[version].append(name)
213 classes[name] = members
214
215# /* Header for OXM experimenter match fields. */
216# struct ofp_oxm_experimenter_header {
217# uint32_t oxm_header; /* oxm_class = OFPXMC_EXPERIMENTER */
218# uint32_t experimenter; /* Experimenter ID which takes the same
219# form as in struct ofp_experimenter_header. */
220# };
221
222
223# enum ofp_vlan_id {
224# OFPVID_PRESENT = 0x1000,
225# OFPVID_NONE = 0x0000,
226# };
227
228# #define OFP_VLAN_NONE OFPVID_NONE