]>
Commit | Line | Data |
---|---|---|
7c5a3bbf AW |
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" | |
b2ce05ed | 24 | #include "openvswitch/hmap.h" |
7c5a3bbf AW |
25 | |
26 | #define OVS_CORE_UNSPEC INT_MAX | |
012c0a04 | 27 | #define OVS_NUMA_UNSPEC INT_MAX |
7c5a3bbf | 28 | |
9da2564e AW |
29 | /* Dump of a list of 'struct ovs_numa_info'. */ |
30 | struct ovs_numa_dump { | |
90f9f839 DDP |
31 | struct hmap cores; |
32 | struct hmap numas; | |
9da2564e AW |
33 | }; |
34 | ||
35 | /* A numa_id - core_id pair. */ | |
90f9f839 | 36 | struct ovs_numa_info_core { |
b2ce05ed | 37 | struct hmap_node hmap_node; |
9da2564e | 38 | int numa_id; |
bd5131ba | 39 | unsigned core_id; |
9da2564e AW |
40 | }; |
41 | ||
90f9f839 DDP |
42 | /* A numa node. */ |
43 | struct ovs_numa_info_numa { | |
44 | struct hmap_node hmap_node; | |
45 | int numa_id; | |
46 | size_t n_cores; | |
47 | }; | |
48 | ||
7c5a3bbf | 49 | void ovs_numa_init(void); |
b4e28b7f | 50 | void ovs_numa_set_dummy(const char *dummy_config); |
012c0a04 | 51 | bool ovs_numa_numa_id_is_valid(int numa_id); |
bd5131ba | 52 | bool ovs_numa_core_id_is_valid(unsigned core_id); |
012c0a04 | 53 | int ovs_numa_get_n_numas(void); |
7c5a3bbf | 54 | int ovs_numa_get_n_cores(void); |
bd5131ba | 55 | int ovs_numa_get_numa_id(unsigned core_id); |
012c0a04 | 56 | int ovs_numa_get_n_cores_on_numa(int numa_id); |
9da2564e | 57 | struct ovs_numa_dump *ovs_numa_dump_cores_on_numa(int numa_id); |
dbedeb9d DDP |
58 | struct ovs_numa_dump *ovs_numa_dump_cores_with_cmask(const char *cmask); |
59 | struct ovs_numa_dump *ovs_numa_dump_n_cores_per_numa(int n); | |
b2ce05ed DDP |
60 | bool ovs_numa_dump_contains_core(const struct ovs_numa_dump *, |
61 | int numa_id, unsigned core_id); | |
90f9f839 | 62 | size_t ovs_numa_dump_count(const struct ovs_numa_dump *); |
9da2564e | 63 | void ovs_numa_dump_destroy(struct ovs_numa_dump *); |
6930c7e0 | 64 | int ovs_numa_thread_setaffinity_core(unsigned core_id); |
9da2564e | 65 | |
dbedeb9d | 66 | #define FOR_EACH_CORE_ON_DUMP(ITER, DUMP) \ |
90f9f839 DDP |
67 | HMAP_FOR_EACH((ITER), hmap_node, &(DUMP)->cores) |
68 | ||
69 | #define FOR_EACH_NUMA_ON_DUMP(ITER, DUMP) \ | |
70 | HMAP_FOR_EACH((ITER), hmap_node, &(DUMP)->numas) | |
7c5a3bbf | 71 | |
93ce5762 | 72 | #endif /* ovs-numa.h */ |