1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
5 #ifndef __INCLUDE_RTE_LRU_H__
6 #define __INCLUDE_RTE_LRU_H__
12 #include <rte_config.h>
13 #ifdef RTE_ARCH_X86_64
14 #include "rte_lru_x86.h"
15 #elif defined(RTE_ARCH_ARM64)
16 #include "rte_lru_arm64.h"
18 #undef RTE_TABLE_HASH_LRU_STRATEGY
19 #define RTE_TABLE_HASH_LRU_STRATEGY 1
22 #if RTE_TABLE_HASH_LRU_STRATEGY == 0
24 #define lru_init(bucket) \
29 #define lru_pos(bucket) (bucket->lru_list & 0xFFFFLLU)
31 #define lru_update(bucket, mru_val) \
37 #elif RTE_TABLE_HASH_LRU_STRATEGY == 1
39 #define lru_init(bucket) \
41 bucket->lru_list = 0x0000000100020003LLU; \
44 #define lru_pos(bucket) (bucket->lru_list & 0xFFFFLLU)
46 #define lru_update(bucket, mru_val) \
48 uint64_t x, pos, x0, x1, x2, mask; \
50 x = bucket->lru_list; \
53 if ((x >> 48) == ((uint64_t) mru_val)) \
56 if (((x >> 32) & 0xFFFFLLU) == ((uint64_t) mru_val)) \
59 if (((x >> 16) & 0xFFFFLLU) == ((uint64_t) mru_val)) \
62 if ((x & 0xFFFFLLU) == ((uint64_t) mru_val)) \
67 mask = (~0LLU) << pos; \
69 x1 = (x >> 16) & mask; \
70 x2 = (x << (48 - pos)) & (0xFFFFLLU << 48); \
74 bucket->lru_list = x; \
77 #elif (RTE_TABLE_HASH_LRU_STRATEGY == 2) || (RTE_TABLE_HASH_LRU_STRATEGY == 3)
80 * These strategies are implemented in architecture specific header files.
85 #error "Incorrect value for RTE_TABLE_HASH_LRU_STRATEGY"