1219820Sjeff/*- 2219820Sjeff * Copyright (c) 2010 Isilon Systems, Inc. 3219820Sjeff * Copyright (c) 2010 iX Systems, Inc. 4219820Sjeff * Copyright (c) 2010 Panasas, Inc. 5328653Shselasky * Copyright (c) 2013-2017 Mellanox Technologies, Ltd. 6219820Sjeff * All rights reserved. 7219820Sjeff * 8219820Sjeff * Redistribution and use in source and binary forms, with or without 9219820Sjeff * modification, are permitted provided that the following conditions 10219820Sjeff * are met: 11219820Sjeff * 1. Redistributions of source code must retain the above copyright 12219820Sjeff * notice unmodified, this list of conditions, and the following 13219820Sjeff * disclaimer. 14219820Sjeff * 2. Redistributions in binary form must reproduce the above copyright 15219820Sjeff * notice, this list of conditions and the following disclaimer in the 16219820Sjeff * documentation and/or other materials provided with the distribution. 17219820Sjeff * 18219820Sjeff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19219820Sjeff * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20219820Sjeff * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21219820Sjeff * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22219820Sjeff * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23219820Sjeff * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24219820Sjeff * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25219820Sjeff * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26219820Sjeff * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27219820Sjeff * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28289644Shselasky * 29289644Shselasky * $FreeBSD: stable/11/sys/compat/linuxkpi/common/include/linux/kthread.h 328653 2018-02-01 13:01:44Z hselasky $ 30219820Sjeff */ 31219820Sjeff#ifndef _LINUX_KTHREAD_H_ 32219820Sjeff#define _LINUX_KTHREAD_H_ 33219820Sjeff 34219820Sjeff#include <linux/sched.h> 35219820Sjeff 36328653Shselasky#include <sys/unistd.h> 37328653Shselasky#include <sys/kthread.h> 38219820Sjeff 39328653Shselasky#define kthread_run(fn, data, fmt, ...) ({ \ 40328653Shselasky struct task_struct *__task; \ 41328653Shselasky struct thread *__td; \ 42219820Sjeff \ 43328653Shselasky if (kthread_add(linux_kthread_fn, NULL, NULL, &__td, \ 44328653Shselasky RFSTOPPED, 0, fmt, ## __VA_ARGS__)) \ 45328653Shselasky __task = NULL; \ 46328653Shselasky else \ 47328653Shselasky __task = linux_kthread_setup_and_run(__td, fn, data); \ 48328653Shselasky __task; \ 49219820Sjeff}) 50219820Sjeff 51328653Shselaskyint linux_kthread_stop(struct task_struct *); 52328653Shselaskybool linux_kthread_should_stop_task(struct task_struct *); 53328653Shselaskybool linux_kthread_should_stop(void); 54328653Shselaskyint linux_kthread_park(struct task_struct *); 55328653Shselaskyvoid linux_kthread_parkme(void); 56328653Shselaskybool linux_kthread_should_park(void); 57328653Shselaskyvoid linux_kthread_unpark(struct task_struct *); 58328653Shselaskyvoid linux_kthread_fn(void *); 59328653Shselaskystruct task_struct *linux_kthread_setup_and_run(struct thread *, 60328653Shselasky linux_task_fn_t *, void *arg); 61328653Shselaskyint linux_in_atomic(void); 62219820Sjeff 63328653Shselasky#define kthread_stop(task) linux_kthread_stop(task) 64328653Shselasky#define kthread_should_stop() linux_kthread_should_stop() 65328653Shselasky#define kthread_should_stop_task(task) linux_kthread_should_stop_task(task) 66328653Shselasky#define kthread_park(task) linux_kthread_park(task) 67328653Shselasky#define kthread_parkme() linux_kthread_parkme() 68328653Shselasky#define kthread_should_park() linux_kthread_should_park() 69328653Shselasky#define kthread_unpark(task) linux_kthread_unpark(task) 70219820Sjeff 71328653Shselasky#define in_atomic() linux_in_atomic() 72219820Sjeff 73328653Shselasky#endif /* _LINUX_KTHREAD_H_ */ 74