4f2f5cd81ea68c392fd641e0705cffc6709811ef
[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
23 #define MAX_TSC        __UINT64_C(0xFFFFFFFFFFFFFFFF)
24
25 void check_expire_cpe(void* data)
26 {
27         struct expire_cpe *um = (struct expire_cpe *)data;
28         uint64_t cur_tsc = rte_rdtsc();
29         struct cpe_data *entries[4] = {0};
30         void *key[4] = {0};
31         uint64_t n_buckets = get_bucket_key8(um->cpe_table, um->bucket_index, key, (void**)entries);
32
33         for (uint8_t i = 0; i < 4 && entries[i]; ++i) {
34                 if (entries[i]->tsc < cur_tsc) {
35                         int key_found = 0;
36                         void* entry = 0;
37                         rte_table_hash_key8_ext_dosig_ops.f_delete(um->cpe_table, key[i], &key_found, entry);
38                 }
39         }
40
41         um->bucket_index++;
42         um->bucket_index &= (n_buckets - 1);
43 }