1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright(c) 2015 - 2020 Intel Corporation.
6 #ifndef _HFI1_AFFINITY_H
7 #define _HFI1_AFFINITY_H
19 /* Can be used for both memory and cpu */
33 struct hfi1_msix_entry;
35 /* Initialize non-HT cpu cores mask */
36 void init_real_cpu_mask(void);
37 /* Initialize driver affinity data */
38 int hfi1_dev_affinity_init(struct hfi1_devdata *dd);
40 * Set IRQ affinity to a CPU. The function will determine the
41 * CPU and set the affinity to it.
43 int hfi1_get_irq_affinity(struct hfi1_devdata *dd,
44 struct hfi1_msix_entry *msix);
46 * Remove the IRQ's CPU affinity. This function also updates
47 * any internal CPU tracking data
49 void hfi1_put_irq_affinity(struct hfi1_devdata *dd,
50 struct hfi1_msix_entry *msix);
52 * Determine a CPU affinity for a user process, if the process does not
53 * have an affinity set yet.
55 int hfi1_get_proc_affinity(int node);
56 /* Release a CPU used by a user process. */
57 void hfi1_put_proc_affinity(int cpu);
59 struct hfi1_affinity_node {
61 u16 __percpu *comp_vect_affinity;
62 struct cpu_mask_set def_intr;
63 struct cpu_mask_set rcv_intr;
64 struct cpumask general_intr_mask;
65 struct cpumask comp_vect_mask;
66 struct list_head list;
69 struct hfi1_affinity_node_list {
70 struct list_head list;
71 struct cpumask real_cpu_mask;
72 struct cpu_mask_set proc;
73 int num_core_siblings;
74 int num_possible_nodes;
77 struct mutex lock; /* protects affinity nodes */
80 int node_affinity_init(void);
81 void node_affinity_destroy_all(void);
82 extern struct hfi1_affinity_node_list node_affinity;
83 void hfi1_dev_affinity_clean_up(struct hfi1_devdata *dd);
84 int hfi1_comp_vect_mappings_lookup(struct rvt_dev_info *rdi, int comp_vect);
85 int hfi1_comp_vectors_set_up(struct hfi1_devdata *dd);
86 void hfi1_comp_vectors_clean_up(struct hfi1_devdata *dd);
88 #endif /* _HFI1_AFFINITY_H */