DPDK 25.03.0-rc0
rte_lru_arm64.h
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Cavium, Inc
3 */
4
5#ifndef __RTE_LRU_ARM64_H__
6#define __RTE_LRU_ARM64_H__
7
8#include <stdint.h>
9#include <rte_vect.h>
10#include <rte_bitops.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16#ifndef RTE_TABLE_HASH_LRU_STRATEGY
17#ifdef __ARM_NEON
18#define RTE_TABLE_HASH_LRU_STRATEGY 3
19#else /* if no NEON, use simple scalar version */
20#define RTE_TABLE_HASH_LRU_STRATEGY 1
21#endif
22#endif
23
24#if RTE_TABLE_HASH_LRU_STRATEGY == 3
25
26#define lru_init(bucket) \
27 { bucket->lru_list = ~0LLU; }
28
29static inline int
30f_lru_pos(uint64_t lru_list)
31{
32 /* Compare the vector to zero vector */
33 uint16x4_t lru_vec = vld1_u16((uint16_t *)&lru_list);
34 uint16x4_t min_vec = vmov_n_u16(vminv_u16(lru_vec));
35 uint64_t mask = vget_lane_u64(vreinterpret_u64_u16(
36 vceq_u16(min_vec, lru_vec)), 0);
37 return rte_clz64(mask) >> 4;
38}
39#define lru_pos(bucket) f_lru_pos(bucket->lru_list)
40
41#define lru_update(bucket, mru_val) \
42do { \
43 const uint64_t orvals[] = {0xFFFFLLU, 0xFFFFLLU << 16, \
44 0xFFFFLLU << 32, 0xFFFFLLU << 48, 0LLU}; \
45 const uint64_t decs[] = {0x1000100010001LLU, 0}; \
46 uint64x1_t lru = vdup_n_u64(bucket->lru_list); \
47 uint64x1_t vdec = vdup_n_u64(decs[mru_val>>2]); \
48 bucket->lru_list = vget_lane_u64(vreinterpret_u64_u16( \
49 vsub_u16(vreinterpret_u16_u64(lru), \
50 vreinterpret_u16_u64(vdec))), \
51 0); \
52 bucket->lru_list |= orvals[mru_val]; \
53} while (0)
54
55#endif
56
57#ifdef __cplusplus
58}
59#endif
60
61#endif
static unsigned int rte_clz64(uint64_t v)
Definition: rte_bitops.h:986