padata.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #include <linux/timer.h>
  26. struct padata_priv {
  27. struct list_head list;
  28. struct parallel_data *pd;
  29. int cb_cpu;
  30. int seq_nr;
  31. int info;
  32. void (*parallel)(struct padata_priv *padata);
  33. void (*serial)(struct padata_priv *padata);
  34. };
  35. struct padata_list {
  36. struct list_head list;
  37. spinlock_t lock;
  38. };
  39. struct padata_queue {
  40. struct padata_list parallel;
  41. struct padata_list reorder;
  42. struct padata_list serial;
  43. struct work_struct pwork;
  44. struct work_struct swork;
  45. struct parallel_data *pd;
  46. atomic_t num_obj;
  47. int cpu_index;
  48. };
  49. struct parallel_data {
  50. struct padata_instance *pinst;
  51. struct padata_queue *queue;
  52. atomic_t seq_nr;
  53. atomic_t reorder_objects;
  54. atomic_t refcnt;
  55. unsigned int max_seq_nr;
  56. cpumask_var_t cpumask;
  57. spinlock_t lock;
  58. struct timer_list timer;
  59. };
  60. struct padata_instance {
  61. struct notifier_block cpu_notifier;
  62. struct workqueue_struct *wq;
  63. struct parallel_data *pd;
  64. cpumask_var_t cpumask;
  65. struct mutex lock;
  66. u8 flags;
  67. #define PADATA_INIT 1
  68. #define PADATA_RESET 2
  69. };
  70. extern struct padata_instance *padata_alloc(const struct cpumask *cpumask,
  71. struct workqueue_struct *wq);
  72. extern void padata_free(struct padata_instance *pinst);
  73. extern int padata_do_parallel(struct padata_instance *pinst,
  74. struct padata_priv *padata, int cb_cpu);
  75. extern void padata_do_serial(struct padata_priv *padata);
  76. extern int padata_set_cpumask(struct padata_instance *pinst,
  77. cpumask_var_t cpumask);
  78. extern int padata_add_cpu(struct padata_instance *pinst, int cpu);
  79. extern int padata_remove_cpu(struct padata_instance *pinst, int cpu);
  80. extern void padata_start(struct padata_instance *pinst);
  81. extern void padata_stop(struct padata_instance *pinst);
  82. #endif