xref: /linux/drivers/usb/gadget/function/u_rndis.h (revision 00afb1811fa638dacf125dd1c343b7a181624dfd)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * u_rndis.h
4  *
5  * Utility definitions for the subset function
6  *
7  * Copyright (c) 2013 Samsung Electronics Co., Ltd.
8  *		http://www.samsung.com
9  *
10  * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
11  */
12 
13 #ifndef U_RNDIS_H
14 #define U_RNDIS_H
15 
16 #include <linux/usb/composite.h>
17 
18 /**
19  * struct f_rndis_opts - RNDIS function options
20  * @func_inst: USB function instance.
21  * @vendor_id: Vendor ID.
22  * @manufacturer: Manufacturer string.
23  * @net: The net_device associated with the RNDIS function.
24  * @bind_count: Tracks the number of configurations the RNDIS function is
25  *              bound to, preventing double-registration of the @net device.
26  * @borrowed_net: True if the net_device is shared and pre-registered during
27  *                the legacy composite driver's bind phase (e.g., multi.c).
28  *                If false, the RNDIS function will register the net_device
29  *                during its own bind phase.
30  * @rndis_interf_group: ConfigFS group for RNDIS interface.
31  * @rndis_os_desc: USB OS descriptor for RNDIS.
32  * @rndis_ext_compat_id: Extended compatibility ID.
33  * @class: USB class.
34  * @subclass: USB subclass.
35  * @protocol: USB protocol.
36  * @lock: Protects the data from concurrent access by configfs read/write
37  *        and create symlink/remove symlink operations.
38  * @refcnt: Reference counter for the function instance.
39  */
40 struct f_rndis_opts {
41 	struct usb_function_instance	func_inst;
42 	u32				vendor_id;
43 	const char			*manufacturer;
44 	struct net_device		*net;
45 	int				bind_count;
46 	bool				borrowed_net;
47 
48 	struct config_group		*rndis_interf_group;
49 	struct usb_os_desc		rndis_os_desc;
50 	char				rndis_ext_compat_id[16];
51 
52 	u8				class;
53 	u8				subclass;
54 	u8				protocol;
55 	struct mutex			lock;
56 	int				refcnt;
57 };
58 
59 void rndis_borrow_net(struct usb_function_instance *f, struct net_device *net);
60 
61 #endif /* U_RNDIS_H */
62