^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright(c) 2015 - 2020 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This file is provided under a dual BSD/GPLv2 license. When using or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * redistributing this file, you may do so under either license.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * GPL LICENSE SUMMARY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * it under the terms of version 2 of the GNU General Public License as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This program is distributed in the hope that it will be useful, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * BSD LICENSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * - Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * - Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * notice, this list of conditions and the following disclaimer in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * - Neither the name of Intel Corporation nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #ifndef _HFI1_AFFINITY_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define _HFI1_AFFINITY_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include "hfi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) enum irq_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) IRQ_SDMA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) IRQ_RCVCTXT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) IRQ_NETDEVCTXT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) IRQ_GENERAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) IRQ_OTHER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /* Can be used for both memory and cpu */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) enum affinity_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) AFF_AUTO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) AFF_NUMA_LOCAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) AFF_DEV_LOCAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) AFF_IRQ_LOCAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct cpu_mask_set {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct cpumask mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct cpumask used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) uint gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct hfi1_msix_entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /* Initialize non-HT cpu cores mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) void init_real_cpu_mask(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* Initialize driver affinity data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) int hfi1_dev_affinity_init(struct hfi1_devdata *dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * Set IRQ affinity to a CPU. The function will determine the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * CPU and set the affinity to it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) int hfi1_get_irq_affinity(struct hfi1_devdata *dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct hfi1_msix_entry *msix);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * Remove the IRQ's CPU affinity. This function also updates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * any internal CPU tracking data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) void hfi1_put_irq_affinity(struct hfi1_devdata *dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct hfi1_msix_entry *msix);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * Determine a CPU affinity for a user process, if the process does not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) * have an affinity set yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) int hfi1_get_proc_affinity(int node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* Release a CPU used by a user process. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) void hfi1_put_proc_affinity(int cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct hfi1_affinity_node {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) int node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) u16 __percpu *comp_vect_affinity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct cpu_mask_set def_intr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct cpu_mask_set rcv_intr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) struct cpumask general_intr_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct cpumask comp_vect_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct hfi1_affinity_node_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct cpumask real_cpu_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct cpu_mask_set proc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) int num_core_siblings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int num_possible_nodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int num_online_nodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int num_online_cpus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct mutex lock; /* protects affinity nodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) int node_affinity_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) void node_affinity_destroy_all(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) extern struct hfi1_affinity_node_list node_affinity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) void hfi1_dev_affinity_clean_up(struct hfi1_devdata *dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) int hfi1_comp_vect_mappings_lookup(struct rvt_dev_info *rdi, int comp_vect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int hfi1_comp_vectors_set_up(struct hfi1_devdata *dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) void hfi1_comp_vectors_clean_up(struct hfi1_devdata *dd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #endif /* _HFI1_AFFINITY_H */