CT: Perf optimization through prefetch and condition checks in CT
[samplevnf.git] / common / VIL / conntrack / rte_ct_udp.c
1 /*
2 // Copyright (c) 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 #include <stdlib.h>
18 #include <string.h>
19 #include "rte_ct_tcp.h"
20 #include "rte_cnxn_tracking.h"
21
22 uint8_t rte_ct_udp_new_connection(__rte_unused struct rte_ct_cnxn_tracker *ct,
23                 struct rte_ct_cnxn_data *cd,
24                 __rte_unused struct rte_mbuf *pkt)
25 {
26         /* printf("New connection UDP packet received\n"); */
27         cd->connstatus = RTE_INIT_CONN;
28         return 1;
29 }
30 enum rte_ct_packet_action rte_ct_udp_packet(struct rte_ct_cnxn_tracker *ct,
31                 struct rte_ct_cnxn_data *cd,
32                 __rte_unused struct rte_mbuf *pkt,
33                 uint8_t  key_was_flipped)
34 {
35         enum rte_ct_pkt_direction dir;
36         enum rte_ct_udp_states ustate = RTE_CT_UDP_UNREPLIED;
37         dir = (cd->key_is_client_order == !key_was_flipped);
38         /* printf("packet received verify"); */
39         if (dir == RTE_CT_DIR_REPLY && (
40                         (cd->connstatus == RTE_INIT_CONN) ||
41                         (cd->connstatus == RTE_ASSURED_CONN)))
42         {
43                 ustate = RTE_CT_UDP_REPLIED;
44                 cd->connstatus = RTE_ASSURED_CONN;
45         }
46         rte_ct_set_cnxn_timer_for_udp(ct, cd, ustate);
47
48         return RTE_CT_FORWARD_PACKET;
49 }