padata.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * padata.h - header for the padata parallelization interface
  3. *
  4. * Copyright (C) 2008, 2009 secunet Security Networks AG
  5. * Copyright (C) 2008, 2009 Steffen Klassert <steffen.klassert@secunet.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms and conditions of the GNU General Public License,
  9. * version 2, as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #ifndef PADATA_H
  21. #define PADATA_H
  22. #include <linux/workqueue.h>
  23. #include <linux/spinlock.h>
  24. #include <linux/list.h>
  25. struct padata_priv {
  26. struct list_head list;
  27. struct parallel_data *pd;
  28. int cb_cpu;
  29. int seq_nr;
  30. int info;
  31. void (*parallel)(struct padata_priv *padata);
  32. void (*serial)(struct padata_priv *padata);
  33. };
  34. struct padata_list {
  35. struct list_head list;
  36. spinlock_t lock;
  37. };
  38. struct padata_queue {
  39. struct padata_list parallel;
  40. struct padata_list reorder;
  41. struct padata_list serial;
  42. struct work_struct pwork;
  43. struct work_struct swork;
  44. struct parallel_data *pd;
  45. atomic_t num_obj;
  46. int cpu_index;
  47. };
  48. struct parallel_data {
  49. struct padata_instance *pinst;
  50. struct padata_queue *queue;
  51. atomic_t seq_nr;
  52. atomic_t reorder_objects;
  53. atomic_t refcnt;
  54. unsigned int max_seq_nr;
  55. cpumask_var_t cpumask;
  56. spinlock_t lock;
  57. };
  58. struct padata_instance {
  59. struct notifier_block cpu_notifier;
  60. struct workqueue_struct *wq;
  61. struct parallel_data *pd;
  62. cpumask_var_t cpumask;
  63. struct mutex lock;
  64. u8 flags;
  65. #define PADATA_INIT 1
  66. #define PADATA_RESET 2
  67. };
  68. extern struct padata_instance *padata_alloc(const struct cpumask *cpumask,
  69. struct workqueue_struct *wq);
  70. extern void padata_free(struct padata_instance *pinst);
  71. extern int padata_do_parallel(struct padata_instance *pinst,
  72. struct padata_priv *padata, int cb_cpu);
  73. extern void padata_do_serial(struct padata_priv *padata);
  74. extern int padata_set_cpumask(struct padata_instance *pinst,
  75. cpumask_var_t cpumask);
  76. extern int padata_add_cpu(struct padata_instance *pinst, int cpu);
  77. extern int padata_remove_cpu(struct padata_instance *pinst, int cpu);
  78. extern void padata_start(struct padata_instance *pinst);
  79. extern void padata_stop(struct padata_instance *pinst);
  80. #endif