Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
0002 /*
0003  * Copyright(c) 2015 - 2020 Intel Corporation.
0004  */
0005 
0006 #ifndef _HFI1_AFFINITY_H
0007 #define _HFI1_AFFINITY_H
0008 
0009 #include "hfi.h"
0010 
0011 enum irq_type {
0012     IRQ_SDMA,
0013     IRQ_RCVCTXT,
0014     IRQ_NETDEVCTXT,
0015     IRQ_GENERAL,
0016     IRQ_OTHER
0017 };
0018 
0019 /* Can be used for both memory and cpu */
0020 enum affinity_flags {
0021     AFF_AUTO,
0022     AFF_NUMA_LOCAL,
0023     AFF_DEV_LOCAL,
0024     AFF_IRQ_LOCAL
0025 };
0026 
0027 struct cpu_mask_set {
0028     struct cpumask mask;
0029     struct cpumask used;
0030     uint gen;
0031 };
0032 
0033 struct hfi1_msix_entry;
0034 
0035 /* Initialize non-HT cpu cores mask */
0036 void init_real_cpu_mask(void);
0037 /* Initialize driver affinity data */
0038 int hfi1_dev_affinity_init(struct hfi1_devdata *dd);
0039 /*
0040  * Set IRQ affinity to a CPU. The function will determine the
0041  * CPU and set the affinity to it.
0042  */
0043 int hfi1_get_irq_affinity(struct hfi1_devdata *dd,
0044               struct hfi1_msix_entry *msix);
0045 /*
0046  * Remove the IRQ's CPU affinity. This function also updates
0047  * any internal CPU tracking data
0048  */
0049 void hfi1_put_irq_affinity(struct hfi1_devdata *dd,
0050                struct hfi1_msix_entry *msix);
0051 /*
0052  * Determine a CPU affinity for a user process, if the process does not
0053  * have an affinity set yet.
0054  */
0055 int hfi1_get_proc_affinity(int node);
0056 /* Release a CPU used by a user process. */
0057 void hfi1_put_proc_affinity(int cpu);
0058 
0059 struct hfi1_affinity_node {
0060     int node;
0061     u16 __percpu *comp_vect_affinity;
0062     struct cpu_mask_set def_intr;
0063     struct cpu_mask_set rcv_intr;
0064     struct cpumask general_intr_mask;
0065     struct cpumask comp_vect_mask;
0066     struct list_head list;
0067 };
0068 
0069 struct hfi1_affinity_node_list {
0070     struct list_head list;
0071     struct cpumask real_cpu_mask;
0072     struct cpu_mask_set proc;
0073     int num_core_siblings;
0074     int num_possible_nodes;
0075     int num_online_nodes;
0076     int num_online_cpus;
0077     struct mutex lock; /* protects affinity nodes */
0078 };
0079 
0080 int node_affinity_init(void);
0081 void node_affinity_destroy_all(void);
0082 extern struct hfi1_affinity_node_list node_affinity;
0083 void hfi1_dev_affinity_clean_up(struct hfi1_devdata *dd);
0084 int hfi1_comp_vect_mappings_lookup(struct rvt_dev_info *rdi, int comp_vect);
0085 int hfi1_comp_vectors_set_up(struct hfi1_devdata *dd);
0086 void hfi1_comp_vectors_clean_up(struct hfi1_devdata *dd);
0087 
0088 #endif /* _HFI1_AFFINITY_H */