Add support for DPDK 17.11
[samplevnf.git] / VNFs / DPPD-PROX / expire_cpe.c
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 #include <rte_cycles.h>
18
19 #include "hash_entry_types.h"
20 #include "hash_utils.h"
21 #include "expire_cpe.h"
22 #include "prox_compat.h"
23
24 #define MAX_TSC        __UINT64_C(0xFFFFFFFFFFFFFFFF)
25
26 void check_expire_cpe(void* data)
27 {
28         struct expire_cpe *um = (struct expire_cpe *)data;
29         uint64_t cur_tsc = rte_rdtsc();
30         struct cpe_data *entries[4] = {0};
31         void *key[4] = {0};
32         uint64_t n_buckets = get_bucket_key8(um->cpe_table, um->bucket_index, key, (void**)entries);
33
34         for (uint8_t i = 0; i < 4 && entries[i]; ++i) {
35                 if (entries[i]->tsc < cur_tsc) {
36                         int key_found = 0;
37                         void* entry = 0;
38                         prox_rte_table_key8_delete(um->cpe_table, key[i], &key_found, entry);
39                 }
40         }
41
42         um->bucket_index++;
43         um->bucket_index &= (n_buckets - 1);
44 }