xref: /linux/drivers/md/dm-vdo/funnel-workqueue.h (revision b4db9f840283caca0d904436f187ef56a9126eaa)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright 2023 Red Hat
4  */
5 
6 #ifndef VDO_WORK_QUEUE_H
7 #define VDO_WORK_QUEUE_H
8 
9 #include <linux/sched.h> /* for TASK_COMM_LEN */
10 
11 #include "types.h"
12 
13 enum {
14 	MAX_VDO_WORK_QUEUE_NAME_LEN = TASK_COMM_LEN,
15 };
16 
17 struct vdo_work_queue_type {
18 	void (*start)(void *context);
19 	void (*finish)(void *context);
20 	enum vdo_completion_priority max_priority;
21 	enum vdo_completion_priority default_priority;
22 };
23 
24 struct vdo_completion;
25 struct vdo_thread;
26 struct vdo_work_queue;
27 
28 int vdo_make_work_queue(const char *thread_name_prefix, const char *name,
29 			struct vdo_thread *owner, const struct vdo_work_queue_type *type,
30 			unsigned int thread_count, void *thread_privates[],
31 			struct vdo_work_queue **queue_ptr);
32 
33 void vdo_enqueue_work_queue(struct vdo_work_queue *queue, struct vdo_completion *completion);
34 
35 void vdo_finish_work_queue(struct vdo_work_queue *queue);
36 
37 void vdo_free_work_queue(struct vdo_work_queue *queue);
38 
39 void vdo_dump_work_queue(struct vdo_work_queue *queue);
40 
41 void vdo_dump_completion_to_buffer(struct vdo_completion *completion, char *buffer,
42 				   size_t length);
43 
44 void *vdo_get_work_queue_private_data(void);
45 struct vdo_work_queue *vdo_get_current_work_queue(void);
46 struct vdo_thread *vdo_get_work_queue_owner(struct vdo_work_queue *queue);
47 
48 bool __must_check vdo_work_queue_type_is(struct vdo_work_queue *queue,
49 					 const struct vdo_work_queue_type *type);
50 
51 #endif /* VDO_WORK_QUEUE_H */
52