116295becSSteffen Klassert /* 216295becSSteffen Klassert * padata.h - header for the padata parallelization interface 316295becSSteffen Klassert * 416295becSSteffen Klassert * Copyright (C) 2008, 2009 secunet Security Networks AG 516295becSSteffen Klassert * Copyright (C) 2008, 2009 Steffen Klassert <steffen.klassert@secunet.com> 616295becSSteffen Klassert * 716295becSSteffen Klassert * This program is free software; you can redistribute it and/or modify it 816295becSSteffen Klassert * under the terms and conditions of the GNU General Public License, 916295becSSteffen Klassert * version 2, as published by the Free Software Foundation. 1016295becSSteffen Klassert * 1116295becSSteffen Klassert * This program is distributed in the hope it will be useful, but WITHOUT 1216295becSSteffen Klassert * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1316295becSSteffen Klassert * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 1416295becSSteffen Klassert * more details. 1516295becSSteffen Klassert * 1616295becSSteffen Klassert * You should have received a copy of the GNU General Public License along with 1716295becSSteffen Klassert * this program; if not, write to the Free Software Foundation, Inc., 1816295becSSteffen Klassert * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 1916295becSSteffen Klassert */ 2016295becSSteffen Klassert 2116295becSSteffen Klassert #ifndef PADATA_H 2216295becSSteffen Klassert #define PADATA_H 2316295becSSteffen Klassert 2416295becSSteffen Klassert #include <linux/workqueue.h> 2516295becSSteffen Klassert #include <linux/spinlock.h> 2616295becSSteffen Klassert #include <linux/list.h> 2716295becSSteffen Klassert 2816295becSSteffen Klassert struct padata_priv { 2916295becSSteffen Klassert struct list_head list; 3016295becSSteffen Klassert struct parallel_data *pd; 3116295becSSteffen Klassert int cb_cpu; 3216295becSSteffen Klassert int seq_nr; 3316295becSSteffen Klassert int info; 3416295becSSteffen Klassert void (*parallel)(struct padata_priv *padata); 3516295becSSteffen Klassert void (*serial)(struct padata_priv *padata); 3616295becSSteffen Klassert }; 3716295becSSteffen Klassert 3816295becSSteffen Klassert struct padata_list { 3916295becSSteffen Klassert struct list_head list; 4016295becSSteffen Klassert spinlock_t lock; 4116295becSSteffen Klassert }; 4216295becSSteffen Klassert 4316295becSSteffen Klassert struct padata_queue { 4416295becSSteffen Klassert struct padata_list parallel; 4516295becSSteffen Klassert struct padata_list reorder; 4616295becSSteffen Klassert struct padata_list serial; 4716295becSSteffen Klassert struct work_struct pwork; 4816295becSSteffen Klassert struct work_struct swork; 4916295becSSteffen Klassert struct parallel_data *pd; 5016295becSSteffen Klassert atomic_t num_obj; 5116295becSSteffen Klassert int cpu_index; 5216295becSSteffen Klassert }; 5316295becSSteffen Klassert 5416295becSSteffen Klassert struct parallel_data { 5516295becSSteffen Klassert struct padata_instance *pinst; 5616295becSSteffen Klassert struct padata_queue *queue; 5716295becSSteffen Klassert atomic_t seq_nr; 5816295becSSteffen Klassert atomic_t reorder_objects; 5916295becSSteffen Klassert atomic_t refcnt; 6016295becSSteffen Klassert unsigned int max_seq_nr; 6116295becSSteffen Klassert cpumask_var_t cpumask; 6216295becSSteffen Klassert spinlock_t lock; 6316295becSSteffen Klassert }; 6416295becSSteffen Klassert 6516295becSSteffen Klassert struct padata_instance { 6616295becSSteffen Klassert struct notifier_block cpu_notifier; 6716295becSSteffen Klassert struct workqueue_struct *wq; 6816295becSSteffen Klassert struct parallel_data *pd; 6916295becSSteffen Klassert cpumask_var_t cpumask; 7016295becSSteffen Klassert struct mutex lock; 7116295becSSteffen Klassert u8 flags; 7216295becSSteffen Klassert #define PADATA_INIT 1 7316295becSSteffen Klassert #define PADATA_RESET 2 7416295becSSteffen Klassert }; 7516295becSSteffen Klassert 7616295becSSteffen Klassert extern struct padata_instance *padata_alloc(const struct cpumask *cpumask, 7716295becSSteffen Klassert struct workqueue_struct *wq); 7816295becSSteffen Klassert extern void padata_free(struct padata_instance *pinst); 7916295becSSteffen Klassert extern int padata_do_parallel(struct padata_instance *pinst, 8016295becSSteffen Klassert struct padata_priv *padata, int cb_cpu); 8116295becSSteffen Klassert extern void padata_do_serial(struct padata_priv *padata); 8216295becSSteffen Klassert extern int padata_set_cpumask(struct padata_instance *pinst, 8316295becSSteffen Klassert cpumask_var_t cpumask); 8416295becSSteffen Klassert extern int padata_add_cpu(struct padata_instance *pinst, int cpu); 8516295becSSteffen Klassert extern int padata_remove_cpu(struct padata_instance *pinst, int cpu); 8616295becSSteffen Klassert extern void padata_start(struct padata_instance *pinst); 8716295becSSteffen Klassert extern void padata_stop(struct padata_instance *pinst); 8816295becSSteffen Klassert #endif 89