]> git.proxmox.com Git - mirror_ovs.git/blame - lib/ovs-numa.h
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / lib / ovs-numa.h
CommitLineData
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'. */
30struct 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 36struct 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. */
43struct ovs_numa_info_numa {
44 struct hmap_node hmap_node;
45 int numa_id;
46 size_t n_cores;
47};
48
7c5a3bbf 49void ovs_numa_init(void);
84b99a04 50void ovs_numa_set_dummy(const char *config);
012c0a04 51bool ovs_numa_numa_id_is_valid(int numa_id);
bd5131ba 52bool ovs_numa_core_id_is_valid(unsigned core_id);
012c0a04 53int ovs_numa_get_n_numas(void);
7c5a3bbf 54int ovs_numa_get_n_cores(void);
bd5131ba 55int ovs_numa_get_numa_id(unsigned core_id);
012c0a04 56int ovs_numa_get_n_cores_on_numa(int numa_id);
9da2564e 57struct ovs_numa_dump *ovs_numa_dump_cores_on_numa(int numa_id);
dbedeb9d
DDP
58struct ovs_numa_dump *ovs_numa_dump_cores_with_cmask(const char *cmask);
59struct ovs_numa_dump *ovs_numa_dump_n_cores_per_numa(int n);
b2ce05ed
DDP
60bool ovs_numa_dump_contains_core(const struct ovs_numa_dump *,
61 int numa_id, unsigned core_id);
90f9f839 62size_t ovs_numa_dump_count(const struct ovs_numa_dump *);
42db85f3
IM
63struct ovs_numa_dump * ovs_numa_thread_getaffinity_dump(void);
64int ovs_numa_thread_setaffinity_dump(const struct ovs_numa_dump *);
9da2564e 65void ovs_numa_dump_destroy(struct ovs_numa_dump *);
6930c7e0 66int ovs_numa_thread_setaffinity_core(unsigned core_id);
9da2564e 67
dbedeb9d 68#define FOR_EACH_CORE_ON_DUMP(ITER, DUMP) \
90f9f839
DDP
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)
7c5a3bbf 73
93ce5762 74#endif /* ovs-numa.h */