]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | /* SPDX-License-Identifier: BSD-3-Clause |
2 | * Copyright(c) 2016 Cavium, Inc | |
7c673cae FG |
3 | */ |
4 | ||
5 | #ifndef _THUNDERX_NICVF_H | |
6 | #define _THUNDERX_NICVF_H | |
7 | ||
8 | /* Platform/OS/arch specific abstractions */ | |
9 | ||
10 | /* log */ | |
11 | #include <rte_log.h> | |
12 | #include "../nicvf_logs.h" | |
13 | ||
14 | #define nicvf_log_error(s, ...) PMD_DRV_LOG(ERR, s, ##__VA_ARGS__) | |
15 | ||
16 | #define nicvf_log_debug(s, ...) PMD_DRV_LOG(DEBUG, s, ##__VA_ARGS__) | |
17 | ||
18 | #define nicvf_mbox_log(s, ...) PMD_MBOX_LOG(DEBUG, s, ##__VA_ARGS__) | |
19 | ||
20 | #define nicvf_log(s, ...) fprintf(stderr, s, ##__VA_ARGS__) | |
21 | ||
22 | /* delay */ | |
23 | #include <rte_cycles.h> | |
24 | #define nicvf_delay_us(x) rte_delay_us(x) | |
25 | ||
26 | /* barrier */ | |
27 | #include <rte_atomic.h> | |
28 | #define nicvf_smp_wmb() rte_smp_wmb() | |
29 | #define nicvf_smp_rmb() rte_smp_rmb() | |
30 | ||
31 | /* utils */ | |
32 | #include <rte_common.h> | |
33 | #define nicvf_min(x, y) RTE_MIN(x, y) | |
9f95a23c | 34 | #define nicvf_log2_u32(x) rte_log2_u32(x) |
7c673cae FG |
35 | |
36 | /* byte order */ | |
37 | #include <rte_byteorder.h> | |
38 | #define nicvf_cpu_to_be_64(x) rte_cpu_to_be_64(x) | |
39 | #define nicvf_be_to_cpu_64(x) rte_be_to_cpu_64(x) | |
40 | ||
11fdf7f2 TL |
41 | #define NICVF_BYTE_ORDER RTE_BYTE_ORDER |
42 | #define NICVF_BIG_ENDIAN RTE_BIG_ENDIAN | |
43 | #define NICVF_LITTLE_ENDIAN RTE_LITTLE_ENDIAN | |
44 | ||
7c673cae FG |
45 | /* Constants */ |
46 | #include <rte_ether.h> | |
47 | #define NICVF_MAC_ADDR_SIZE ETHER_ADDR_LEN | |
48 | ||
11fdf7f2 TL |
49 | #include <rte_io.h> |
50 | #define nicvf_addr_write(addr, val) rte_write64_relaxed((val), (void *)(addr)) | |
51 | #define nicvf_addr_read(addr) rte_read64_relaxed((void *)(addr)) | |
52 | ||
7c673cae FG |
53 | /* ARM64 specific functions */ |
54 | #if defined(RTE_ARCH_ARM64) | |
55 | #define nicvf_prefetch_store_keep(_ptr) ({\ | |
9f95a23c | 56 | asm volatile("prfm pstl1keep, [%x0]\n" : : "r" (_ptr)); }) |
7c673cae | 57 | |
7c673cae FG |
58 | |
59 | #define NICVF_LOAD_PAIR(reg1, reg2, addr) ({ \ | |
60 | asm volatile( \ | |
61 | "ldp %x[x1], %x[x0], [%x[p1]]" \ | |
62 | : [x1]"=r"(reg1), [x0]"=r"(reg2)\ | |
63 | : [p1]"r"(addr) \ | |
64 | ); }) | |
65 | ||
66 | #else /* non optimized functions for building on non arm64 arch */ | |
67 | ||
68 | #define nicvf_prefetch_store_keep(_ptr) do {} while (0) | |
69 | ||
7c673cae FG |
70 | #define NICVF_LOAD_PAIR(reg1, reg2, addr) \ |
71 | do { \ | |
72 | reg1 = nicvf_addr_read((uintptr_t)addr); \ | |
73 | reg2 = nicvf_addr_read((uintptr_t)addr + 8); \ | |
74 | } while (0) | |
75 | ||
76 | #endif | |
77 | ||
78 | #include "nicvf_hw.h" | |
79 | #include "nicvf_mbox.h" | |
80 | ||
81 | #endif /* _THUNDERX_NICVF_H */ |