xref: /openbmc/linux/include/net/mctpdevice.h (revision 68635970)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Management Component Transport Protocol (MCTP) - device
4  * definitions.
5  *
6  * Copyright (c) 2021 Code Construct
7  * Copyright (c) 2021 Google
8  */
9 
10 #ifndef __NET_MCTPDEVICE_H
11 #define __NET_MCTPDEVICE_H
12 
13 #include <linux/list.h>
14 #include <linux/types.h>
15 #include <linux/refcount.h>
16 
17 struct mctp_dev {
18 	struct net_device	*dev;
19 
20 	refcount_t		refs;
21 
22 	unsigned int		net;
23 
24 	/* Only modified under RTNL. Reads have addrs_lock held */
25 	u8			*addrs;
26 	size_t			num_addrs;
27 	spinlock_t		addrs_lock;
28 
29 	struct rcu_head		rcu;
30 };
31 
32 #define MCTP_INITIAL_DEFAULT_NET	1
33 
34 struct mctp_dev *mctp_dev_get_rtnl(const struct net_device *dev);
35 struct mctp_dev *__mctp_dev_get(const struct net_device *dev);
36 
37 void mctp_dev_hold(struct mctp_dev *mdev);
38 void mctp_dev_put(struct mctp_dev *mdev);
39 
40 #endif /* __NET_MCTPDEVICE_H */
41