-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathworker.h
73 lines (62 loc) · 1.72 KB
/
worker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2019, 2020 Vitaly Mayatskikh <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2.
*
*/
#ifndef _ETHBLK_WORKER_H_
#define _ETHBLK_WORKER_H_
#include <linux/kthread.h>
#include <linux/cpumask.h>
enum ethblk_worker_rps_type {
ETHBLK_WORKER_RPS_SAME,
ETHBLK_WORKER_RPS_NEIGHBOUR,
ETHBLK_WORKER_RPS_AUTO,
ETHBLK_WORKER_RPS_USERSPACE
};
struct ethblk_worker_pool_rps_stat {
unsigned long long *in; /* requests scheduled from this cpu */
unsigned long long *out; /* requests scheduled to this cpu */
};
struct ethblk_worker_pool_rps {
struct ethblk_worker_pool_rps_stat __percpu *stat;
int cpu_out[NR_CPUS]; /* TODO change to sorted list */
};
enum ethblk_worker_cb_type {
ETHBLK_WORKER_CB_TYPE_INITIATOR_IO,
ETHBLK_WORKER_CB_TYPE_INITIATOR_DISCOVER
};
struct ethblk_worker_cb {
struct list_head list;
void (*fn)(struct ethblk_worker_cb *);
void *data;
enum ethblk_worker_cb_type type :2;
bool in_headroom :1;
unsigned comp_cpu;
};
struct ethblk_worker {
int idx;
struct ethblk_worker_pool *pool;
struct kthread_worker *worker;
struct kthread_work work;
bool active;
raw_spinlock_t lock;
struct list_head queue;
};
struct ethblk_worker_pool {
char name[16];
struct kmem_cache *cb_cache;
struct cpumask cpumask;
struct timer_list rps_reconfig_timer;
struct ethblk_worker worker[NR_CPUS];
struct ethblk_worker_pool_rps rps;
};
int
ethblk_worker_create_pool(struct ethblk_worker_pool **p, const char *name,
kthread_work_func_t fn,
const struct cpumask *cpumask);
void ethblk_worker_destroy_pool(struct ethblk_worker_pool *p);
bool ethblk_worker_enqueue(struct ethblk_worker_pool *p,
struct list_head *list);
#endif