xref: /kernel/linux/linux-5.10/fs/hmdfs/comm/node_cb.h (revision 8c2ecf20)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * fs/hmdfs/comm/node_cb.h
4 *
5 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
6 */
7
8#ifndef HMDFS_NODE_CB_H
9#define HMDFS_NODE_CB_H
10
11#include "hmdfs.h"
12
13/* async & sync */
14#define NODE_EVT_TYPE_NR 2
15
16enum {
17	NODE_EVT_ADD = 0,
18	NODE_EVT_ONLINE,
19	NODE_EVT_OFFLINE,
20	NODE_EVT_DEL,
21	NODE_EVT_NR,
22};
23
24struct hmdfs_peer;
25
26typedef void (*hmdfs_node_evt_cb)(struct hmdfs_peer *conn,
27				  int evt, unsigned int seq);
28
29struct hmdfs_node_cb_desc {
30	int evt;
31	bool sync;
32	hmdfs_node_evt_cb fn;
33	struct list_head list;
34};
35
36extern void hmdfs_node_evt_cb_init(void);
37
38/* Only initialize during module init */
39extern void hmdfs_node_add_evt_cb(struct hmdfs_node_cb_desc *desc, int nr);
40extern void hmdfs_node_call_evt_cb(struct hmdfs_peer *node, int evt, bool sync,
41				   unsigned int seq);
42
43#endif /* HMDFS_NODE_CB_H */
44