]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/dpdk/lib/librte_eal/common/include/arch/x86/rte_cycles.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / seastar / dpdk / lib / librte_eal / common / include / arch / x86 / rte_cycles.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation.
3 * Copyright(c) 2013 6WIND S.A.
4 */
5
6 #ifndef _RTE_CYCLES_X86_64_H_
7 #define _RTE_CYCLES_X86_64_H_
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 #include "generic/rte_cycles.h"
14
15 #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
16 /* Global switch to use VMWARE mapping of TSC instead of RDTSC */
17 extern int rte_cycles_vmware_tsc_map;
18 #include <rte_branch_prediction.h>
19 #endif
20 #include <rte_common.h>
21 #include <rte_config.h>
22
23 static inline uint64_t
24 rte_rdtsc(void)
25 {
26 union {
27 uint64_t tsc_64;
28 RTE_STD_C11
29 struct {
30 uint32_t lo_32;
31 uint32_t hi_32;
32 };
33 } tsc;
34
35 #ifdef RTE_LIBRTE_EAL_VMWARE_TSC_MAP_SUPPORT
36 if (unlikely(rte_cycles_vmware_tsc_map)) {
37 /* ecx = 0x10000 corresponds to the physical TSC for VMware */
38 asm volatile("rdpmc" :
39 "=a" (tsc.lo_32),
40 "=d" (tsc.hi_32) :
41 "c"(0x10000));
42 return tsc.tsc_64;
43 }
44 #endif
45
46 asm volatile("rdtsc" :
47 "=a" (tsc.lo_32),
48 "=d" (tsc.hi_32));
49 return tsc.tsc_64;
50 }
51
52 static inline uint64_t
53 rte_rdtsc_precise(void)
54 {
55 rte_mb();
56 return rte_rdtsc();
57 }
58
59 static inline uint64_t
60 rte_get_tsc_cycles(void) { return rte_rdtsc(); }
61
62 #ifdef __cplusplus
63 }
64 #endif
65
66 #endif /* _RTE_CYCLES_X86_64_H_ */