]> git.proxmox.com Git - mirror_ovs.git/blob - lib/ovs-numa.h
ovsdb-idl: Fix iteration over tracked rows with no actual data.
[mirror_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/hmap.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 hmap cores;
32 struct hmap numas;
33 };
34
35 /* A numa_id - core_id pair. */
36 struct ovs_numa_info_core {
37 struct hmap_node hmap_node;
38 int numa_id;
39 unsigned core_id;
40 };
41
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
49 void ovs_numa_init(void);
50 void ovs_numa_set_dummy(const char *config);
51 bool ovs_numa_numa_id_is_valid(int numa_id);
52 bool ovs_numa_core_id_is_valid(unsigned core_id);
53 int ovs_numa_get_n_numas(void);
54 int ovs_numa_get_n_cores(void);
55 int ovs_numa_get_numa_id(unsigned core_id);
56 int ovs_numa_get_n_cores_on_numa(int numa_id);
57 struct ovs_numa_dump *ovs_numa_dump_cores_on_numa(int numa_id);
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);
60 bool ovs_numa_dump_contains_core(const struct ovs_numa_dump *,
61 int numa_id, unsigned core_id);
62 size_t ovs_numa_dump_count(const struct ovs_numa_dump *);
63 struct ovs_numa_dump * ovs_numa_thread_getaffinity_dump(void);
64 int ovs_numa_thread_setaffinity_dump(const struct ovs_numa_dump *);
65 void ovs_numa_dump_destroy(struct ovs_numa_dump *);
66 int ovs_numa_thread_setaffinity_core(unsigned core_id);
67
68 #define FOR_EACH_CORE_ON_DUMP(ITER, DUMP) \
69 HMAP_FOR_EACH((ITER), hmap_node, &(DUMP)->cores)
70
71 #define FOR_EACH_NUMA_ON_DUMP(ITER, DUMP) \
72 HMAP_FOR_EACH((ITER), hmap_node, &(DUMP)->numas)
73
74 #endif /* ovs-numa.h */