ovs-numa: Replace name 'cpu_socket' with 'numa_node'.
[cascardo/ovs.git] / lib / ovs-numa.h
1 /*
2  * Copyright (c) 2014 Nicira, Inc.
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 #ifndef OVS_NUMA_H
18 #define OVS_NUMA_H 1
19
20 #include <limits.h>
21 #include <stdbool.h>
22
23 #include "compiler.h"
24
25 #define OVS_CORE_UNSPEC INT_MAX
26 #define OVS_NUMA_UNSPEC INT_MAX
27
28 #ifdef __linux__
29
30 void ovs_numa_init(void);
31 bool ovs_numa_numa_id_is_valid(int numa_id);
32 bool ovs_numa_core_id_is_valid(int core_id);
33 int ovs_numa_get_n_numas(void);
34 int ovs_numa_get_n_cores(void);
35 int ovs_numa_get_n_cores_on_numa(int numa_id);
36 int ovs_numa_get_n_unpinned_cores_on_numa(int numa_id);
37 bool ovs_numa_try_pin_core_specific(int core_id);
38 int ovs_numa_get_unpinned_core_any(void);
39 int ovs_numa_get_unpinned_core_on_numa(int numa_id);
40 void ovs_numa_unpin_core(int core_id);
41
42 #else
43
44 static inline void
45 ovs_numa_init(void)
46 {
47     /* Nothing */
48 }
49
50 static inline bool
51 ovs_numa_numa_id_is_valid(int numa_id OVS_UNUSED)
52 {
53     return false;
54 }
55
56 static inline bool
57 ovs_numa_core_id_is_valid(int core_id OVS_UNUSED)
58 {
59     return false;
60 }
61
62 static inline int
63 ovs_numa_get_n_numas(void)
64 {
65     return OVS_NUMA_UNSPEC;
66 }
67
68 static inline int
69 ovs_numa_get_n_cores(void)
70 {
71     return OVS_CORE_UNSPEC;
72 }
73
74 static inline int
75 ovs_numa_get_n_cores_on_numa(int numa_id OVS_UNUSED)
76 {
77     return OVS_CORE_UNSPEC;
78 }
79
80 static inline int
81 ovs_numa_get_n_unpinned_cores_on_numa(int numa_id OVS_UNUSED)
82 {
83     return OVS_CORE_UNSPEC;
84 }
85
86 static inline bool
87 ovs_numa_try_pin_core_specific(int core_id OVS_UNUSED)
88 {
89     return false;
90 }
91
92 static inline int
93 ovs_numa_get_unpinned_core_any(void)
94 {
95     return OVS_CORE_UNSPEC;
96 }
97
98 static inline int
99 ovs_numa_get_unpinned_core_on_numa(int numa_id OVS_UNUSED)
100 {
101     return OVS_CORE_UNSPEC;
102 }
103
104 static inline void
105 ovs_numa_unpin_core(int core_id OVS_UNUSED)
106 {
107     /* Nothing */
108 }
109
110 #endif /* __linux__ */
111 #endif /* ovs-thead.h */