dpif-netlink: add GENEVE creation support
[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 #include "openvswitch/list.h"
25
26 #define OVS_CORE_UNSPEC INT_MAX
27 #define OVS_NUMA_UNSPEC INT_MAX
28
29 /* Dump of a list of 'struct ovs_numa_info'. */
30 struct ovs_numa_dump {
31     struct ovs_list dump;
32 };
33
34 /* A numa_id - core_id pair. */
35 struct ovs_numa_info {
36     struct ovs_list list_node;
37     int numa_id;
38     unsigned core_id;
39 };
40
41 void ovs_numa_init(void);
42 void ovs_numa_set_dummy(const char *dummy_config);
43 bool ovs_numa_numa_id_is_valid(int numa_id);
44 bool ovs_numa_core_id_is_valid(unsigned core_id);
45 bool ovs_numa_core_is_pinned(unsigned core_id);
46 int ovs_numa_get_n_numas(void);
47 void ovs_numa_set_cpu_mask(const char *cmask);
48 int ovs_numa_get_n_cores(void);
49 int ovs_numa_get_numa_id(unsigned core_id);
50 int ovs_numa_get_n_cores_on_numa(int numa_id);
51 int ovs_numa_get_n_unpinned_cores_on_numa(int numa_id);
52 bool ovs_numa_try_pin_core_specific(unsigned core_id);
53 unsigned ovs_numa_get_unpinned_core_any(void);
54 unsigned ovs_numa_get_unpinned_core_on_numa(int numa_id);
55 void ovs_numa_unpin_core(unsigned core_id);
56 struct ovs_numa_dump *ovs_numa_dump_cores_on_numa(int numa_id);
57 void ovs_numa_dump_destroy(struct ovs_numa_dump *);
58 int ovs_numa_thread_setaffinity_core(unsigned core_id);
59
60 #define FOR_EACH_CORE_ON_NUMA(ITER, DUMP)                    \
61     LIST_FOR_EACH((ITER), list_node, &(DUMP)->dump)
62
63 #endif /* ovs-numa.h */