Support packets in flight
[samplevnf.git] / VNFs / DPPD-PROX / acl_field_def.h
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
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 _ACL_FIELD_DEF_H_
18 #define _ACL_FIELD_DEF_H_
19
20 #include <rte_ether.h>
21 #include <rte_ip.h>
22 #include <rte_udp.h>
23
24 #include "qinq.h"
25
26 struct pkt_eth_ipv4_udp {
27         prox_rte_ether_hdr ether_hdr;
28         prox_rte_ipv4_hdr ipv4_hdr;
29         prox_rte_udp_hdr udp_hdr;
30 } __attribute__((packed)) __attribute__((__aligned__(2)));
31
32 static struct rte_acl_field_def pkt_eth_ipv4_udp_defs[] = {
33         /* first input field - always one byte long. */
34         {
35                 .type = RTE_ACL_FIELD_TYPE_BITMASK,
36                 .size = sizeof (uint8_t),
37                 .field_index = 0,
38                 .input_index = 0,
39                 .offset = offsetof (struct pkt_eth_ipv4_udp, ipv4_hdr.next_proto_id),
40         },
41         /* IPv4 source address. */
42         {
43                 .type = RTE_ACL_FIELD_TYPE_MASK,
44                 .size = sizeof (uint32_t),
45                 .field_index = 1,
46                 .input_index = 1,
47                 .offset = offsetof (struct pkt_eth_ipv4_udp, ipv4_hdr.src_addr),
48         },
49         /* IPv4 destination address */
50         {
51                 .type = RTE_ACL_FIELD_TYPE_MASK,
52                 .size = sizeof (uint32_t),
53                 .field_index = 2,
54                 .input_index = 2,
55                 .offset = offsetof (struct pkt_eth_ipv4_udp, ipv4_hdr.dst_addr),
56         },
57         /* (L4 src/dst port) - 4 consecutive bytes. */
58         {
59                 .type = RTE_ACL_FIELD_TYPE_RANGE,
60                 .size = sizeof (uint16_t),
61                 .field_index = 3,
62                 .input_index = 3,
63                 .offset = offsetof (struct pkt_eth_ipv4_udp, udp_hdr.src_port),
64         },
65         {
66                 .type = RTE_ACL_FIELD_TYPE_RANGE,
67                 .size = sizeof (uint16_t),
68                 .field_index = 4,
69                 .input_index = 3,
70                 .offset = offsetof (struct pkt_eth_ipv4_udp, udp_hdr.dst_port),
71         },
72 };
73
74 struct pkt_qinq_ipv4_udp {
75         struct qinq_hdr qinq_hdr;
76         prox_rte_ipv4_hdr ipv4_hdr;
77         prox_rte_udp_hdr udp_hdr;
78 };
79
80 static struct rte_acl_field_def pkt_qinq_ipv4_udp_defs[] = {
81         /* first input field - always one byte long. */
82         {
83                 .type = RTE_ACL_FIELD_TYPE_BITMASK,
84                 .size = sizeof (uint8_t),
85                 .field_index = 0,
86                 .input_index = 0,
87                 .offset = offsetof (struct pkt_qinq_ipv4_udp, ipv4_hdr.next_proto_id),
88         },
89         /* IPv4 source address. */
90         {
91                 .type = RTE_ACL_FIELD_TYPE_MASK,
92                 .size = sizeof (uint32_t),
93                 .field_index = 1,
94                 .input_index = 1,
95                 .offset = offsetof (struct pkt_qinq_ipv4_udp, ipv4_hdr.src_addr),
96         },
97         /* IPv4 destination address */
98         {
99                 .type = RTE_ACL_FIELD_TYPE_MASK,
100                 .size = sizeof (uint32_t),
101                 .field_index = 2,
102                 .input_index = 2,
103                 .offset = offsetof (struct pkt_qinq_ipv4_udp, ipv4_hdr.dst_addr),
104         },
105         /* (L4 src/dst port) - 4 consecutive bytes. */
106         {
107                 .type = RTE_ACL_FIELD_TYPE_RANGE,
108                 .size = sizeof (uint16_t),
109                 .field_index = 3,
110                 .input_index = 3,
111                 .offset = offsetof (struct pkt_qinq_ipv4_udp, udp_hdr.src_port),
112         },
113         {
114                 .type = RTE_ACL_FIELD_TYPE_RANGE,
115                 .size = sizeof (uint16_t),
116                 .field_index = 4,
117                 .input_index = 3,
118                 .offset = offsetof (struct pkt_qinq_ipv4_udp, udp_hdr.dst_port),
119         },
120         /* (SVLAN id + eth type) - 4 consecutive bytes. */
121         {
122                 .type = RTE_ACL_FIELD_TYPE_BITMASK,
123                 .size = sizeof(uint16_t),
124                 .field_index = 5,
125                 .input_index = 4,
126                 .offset = offsetof (struct pkt_qinq_ipv4_udp, qinq_hdr.svlan.eth_proto),
127         },
128         {
129                 .type = RTE_ACL_FIELD_TYPE_BITMASK,
130                 .size = sizeof(uint16_t),
131                 .field_index = 6,
132                 .input_index = 4,
133                 .offset = offsetof (struct pkt_qinq_ipv4_udp, qinq_hdr.svlan.vlan_tci),
134         },
135         /* (CVLAN id + eth type) - 4 consecutive byates. */
136         {
137                 .type = RTE_ACL_FIELD_TYPE_BITMASK,
138                 .size = sizeof(uint16_t),
139                 .field_index = 7,
140                 .input_index = 5,
141                 .offset = offsetof (struct pkt_qinq_ipv4_udp, qinq_hdr.cvlan.eth_proto),
142         },
143         {
144                 .type = RTE_ACL_FIELD_TYPE_BITMASK,
145                 .size = sizeof(uint16_t),
146                 .field_index = 8,
147                 .input_index = 5,
148                 .offset = offsetof (struct pkt_qinq_ipv4_udp, qinq_hdr.cvlan.vlan_tci),
149         },
150 };
151
152 #endif /* _ACL_FIELD_DEF_H_ */