affinity.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0 or BSD-3-Clause */
  2. /*
  3. * Copyright(c) 2015 - 2020 Intel Corporation.
  4. */
  5. #ifndef _HFI1_AFFINITY_H
  6. #define _HFI1_AFFINITY_H
  7. #include "hfi.h"
  8. enum irq_type {
  9. IRQ_SDMA,
  10. IRQ_RCVCTXT,
  11. IRQ_NETDEVCTXT,
  12. IRQ_GENERAL,
  13. IRQ_OTHER
  14. };
  15. /* Can be used for both memory and cpu */
  16. enum affinity_flags {
  17. AFF_AUTO,
  18. AFF_NUMA_LOCAL,
  19. AFF_DEV_LOCAL,
  20. AFF_IRQ_LOCAL
  21. };
  22. struct cpu_mask_set {
  23. struct cpumask mask;
  24. struct cpumask used;
  25. uint gen;
  26. };
  27. struct hfi1_msix_entry;
  28. /* Initialize non-HT cpu cores mask */
  29. void init_real_cpu_mask(void);
  30. /* Initialize driver affinity data */
  31. int hfi1_dev_affinity_init(struct hfi1_devdata *dd);
  32. /*
  33. * Set IRQ affinity to a CPU. The function will determine the
  34. * CPU and set the affinity to it.
  35. */
  36. int hfi1_get_irq_affinity(struct hfi1_devdata *dd,
  37. struct hfi1_msix_entry *msix);
  38. /*
  39. * Remove the IRQ's CPU affinity. This function also updates
  40. * any internal CPU tracking data
  41. */
  42. void hfi1_put_irq_affinity(struct hfi1_devdata *dd,
  43. struct hfi1_msix_entry *msix);
  44. /*
  45. * Determine a CPU affinity for a user process, if the process does not
  46. * have an affinity set yet.
  47. */
  48. int hfi1_get_proc_affinity(int node);
  49. /* Release a CPU used by a user process. */
  50. void hfi1_put_proc_affinity(int cpu);
  51. struct hfi1_affinity_node {
  52. int node;
  53. u16 __percpu *comp_vect_affinity;
  54. struct cpu_mask_set def_intr;
  55. struct cpu_mask_set rcv_intr;
  56. struct cpumask general_intr_mask;
  57. struct cpumask comp_vect_mask;
  58. struct list_head list;
  59. };
  60. struct hfi1_affinity_node_list {
  61. struct list_head list;
  62. struct cpumask real_cpu_mask;
  63. struct cpu_mask_set proc;
  64. int num_core_siblings;
  65. int num_possible_nodes;
  66. int num_online_nodes;
  67. int num_online_cpus;
  68. struct mutex lock; /* protects affinity nodes */
  69. };
  70. int node_affinity_init(void);
  71. void node_affinity_destroy_all(void);
  72. extern struct hfi1_affinity_node_list node_affinity;
  73. void hfi1_dev_affinity_clean_up(struct hfi1_devdata *dd);
  74. int hfi1_comp_vect_mappings_lookup(struct rvt_dev_info *rdi, int comp_vect);
  75. int hfi1_comp_vectors_set_up(struct hfi1_devdata *dd);
  76. void hfi1_comp_vectors_clean_up(struct hfi1_devdata *dd);
  77. #endif /* _HFI1_AFFINITY_H */