xref: /linux/drivers/usb/usbip/usbip_common.h (revision 0ea5c948cb64bab5bc7a5516774eb8536f05aa0d)
15fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0+
296c27377SValentina Manea /*
396c27377SValentina Manea  * Copyright (C) 2003-2008 Takahiro Hirofuchi
4c7af4c22SIgor Kotrasinski  * Copyright (C) 2015-2016 Samsung Electronics
5c7af4c22SIgor Kotrasinski  *               Krzysztof Opasiak <k.opasiak@samsung.com>
696c27377SValentina Manea  */
796c27377SValentina Manea 
896c27377SValentina Manea #ifndef __USBIP_COMMON_H
996c27377SValentina Manea #define __USBIP_COMMON_H
1096c27377SValentina Manea 
1196c27377SValentina Manea #include <linux/compiler.h>
1296c27377SValentina Manea #include <linux/device.h>
1396c27377SValentina Manea #include <linux/interrupt.h>
1496c27377SValentina Manea #include <linux/net.h>
1596c27377SValentina Manea #include <linux/printk.h>
1696c27377SValentina Manea #include <linux/spinlock.h>
1796c27377SValentina Manea #include <linux/types.h>
1896c27377SValentina Manea #include <linux/usb.h>
1996c27377SValentina Manea #include <linux/wait.h>
200881e7bdSIngo Molnar #include <linux/sched/task.h>
21183f47fcSSebastian Andrzej Siewior #include <linux/kcov.h>
2296c27377SValentina Manea #include <uapi/linux/usbip.h>
2396c27377SValentina Manea 
2496c27377SValentina Manea #undef pr_fmt
2596c27377SValentina Manea 
2696c27377SValentina Manea #ifdef DEBUG
2796c27377SValentina Manea #define pr_fmt(fmt)     KBUILD_MODNAME ": %s:%d: " fmt, __func__, __LINE__
2896c27377SValentina Manea #else
2996c27377SValentina Manea #define pr_fmt(fmt)     KBUILD_MODNAME ": " fmt
3096c27377SValentina Manea #endif
3196c27377SValentina Manea 
3296c27377SValentina Manea enum {
3396c27377SValentina Manea 	usbip_debug_xmit	= (1 << 0),
3496c27377SValentina Manea 	usbip_debug_sysfs	= (1 << 1),
3596c27377SValentina Manea 	usbip_debug_urb		= (1 << 2),
3696c27377SValentina Manea 	usbip_debug_eh		= (1 << 3),
3796c27377SValentina Manea 
3896c27377SValentina Manea 	usbip_debug_stub_cmp	= (1 << 8),
3996c27377SValentina Manea 	usbip_debug_stub_dev	= (1 << 9),
4096c27377SValentina Manea 	usbip_debug_stub_rx	= (1 << 10),
4196c27377SValentina Manea 	usbip_debug_stub_tx	= (1 << 11),
4296c27377SValentina Manea 
4396c27377SValentina Manea 	usbip_debug_vhci_rh	= (1 << 8),
4496c27377SValentina Manea 	usbip_debug_vhci_hc	= (1 << 9),
4596c27377SValentina Manea 	usbip_debug_vhci_rx	= (1 << 10),
4696c27377SValentina Manea 	usbip_debug_vhci_tx	= (1 << 11),
4796c27377SValentina Manea 	usbip_debug_vhci_sysfs  = (1 << 12)
4896c27377SValentina Manea };
4996c27377SValentina Manea 
5096c27377SValentina Manea #define usbip_dbg_flag_xmit	(usbip_debug_flag & usbip_debug_xmit)
5196c27377SValentina Manea #define usbip_dbg_flag_vhci_rh	(usbip_debug_flag & usbip_debug_vhci_rh)
5296c27377SValentina Manea #define usbip_dbg_flag_vhci_hc	(usbip_debug_flag & usbip_debug_vhci_hc)
5396c27377SValentina Manea #define usbip_dbg_flag_vhci_rx	(usbip_debug_flag & usbip_debug_vhci_rx)
5496c27377SValentina Manea #define usbip_dbg_flag_vhci_tx	(usbip_debug_flag & usbip_debug_vhci_tx)
5596c27377SValentina Manea #define usbip_dbg_flag_stub_rx	(usbip_debug_flag & usbip_debug_stub_rx)
5696c27377SValentina Manea #define usbip_dbg_flag_stub_tx	(usbip_debug_flag & usbip_debug_stub_tx)
5796c27377SValentina Manea #define usbip_dbg_flag_vhci_sysfs  (usbip_debug_flag & usbip_debug_vhci_sysfs)
5896c27377SValentina Manea 
5996c27377SValentina Manea extern unsigned long usbip_debug_flag;
6096c27377SValentina Manea extern struct device_attribute dev_attr_usbip_debug;
6196c27377SValentina Manea 
6296c27377SValentina Manea #define usbip_dbg_with_flag(flag, fmt, args...)		\
6396c27377SValentina Manea 	do {						\
6496c27377SValentina Manea 		if (flag & usbip_debug_flag)		\
6596c27377SValentina Manea 			pr_debug(fmt, ##args);		\
6696c27377SValentina Manea 	} while (0)
6796c27377SValentina Manea 
6896c27377SValentina Manea #define usbip_dbg_sysfs(fmt, args...) \
6996c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_sysfs, fmt , ##args)
7096c27377SValentina Manea #define usbip_dbg_xmit(fmt, args...) \
7196c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_xmit, fmt , ##args)
7296c27377SValentina Manea #define usbip_dbg_urb(fmt, args...) \
7396c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_urb, fmt , ##args)
7496c27377SValentina Manea #define usbip_dbg_eh(fmt, args...) \
7596c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_eh, fmt , ##args)
7696c27377SValentina Manea 
7796c27377SValentina Manea #define usbip_dbg_vhci_rh(fmt, args...)	\
7896c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_vhci_rh, fmt , ##args)
7996c27377SValentina Manea #define usbip_dbg_vhci_hc(fmt, args...)	\
8096c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_vhci_hc, fmt , ##args)
8196c27377SValentina Manea #define usbip_dbg_vhci_rx(fmt, args...)	\
8296c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_vhci_rx, fmt , ##args)
8396c27377SValentina Manea #define usbip_dbg_vhci_tx(fmt, args...)	\
8496c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_vhci_tx, fmt , ##args)
8596c27377SValentina Manea #define usbip_dbg_vhci_sysfs(fmt, args...) \
8696c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_vhci_sysfs, fmt , ##args)
8796c27377SValentina Manea 
8896c27377SValentina Manea #define usbip_dbg_stub_cmp(fmt, args...) \
8996c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_stub_cmp, fmt , ##args)
9096c27377SValentina Manea #define usbip_dbg_stub_rx(fmt, args...) \
9196c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_stub_rx, fmt , ##args)
9296c27377SValentina Manea #define usbip_dbg_stub_tx(fmt, args...) \
9396c27377SValentina Manea 	usbip_dbg_with_flag(usbip_debug_stub_tx, fmt , ##args)
9496c27377SValentina Manea 
9596c27377SValentina Manea /*
9696c27377SValentina Manea  * USB/IP request headers
9796c27377SValentina Manea  *
9896c27377SValentina Manea  * Each request is transferred across the network to its counterpart, which
9996c27377SValentina Manea  * facilitates the normal USB communication. The values contained in the headers
10096c27377SValentina Manea  * are basically the same as in a URB. Currently, four request types are
10196c27377SValentina Manea  * defined:
10296c27377SValentina Manea  *
10396c27377SValentina Manea  *  - USBIP_CMD_SUBMIT: a USB request block, corresponds to usb_submit_urb()
10496c27377SValentina Manea  *    (client to server)
10596c27377SValentina Manea  *
10696c27377SValentina Manea  *  - USBIP_RET_SUBMIT: the result of USBIP_CMD_SUBMIT
10796c27377SValentina Manea  *    (server to client)
10896c27377SValentina Manea  *
10996c27377SValentina Manea  *  - USBIP_CMD_UNLINK: an unlink request of a pending USBIP_CMD_SUBMIT,
11096c27377SValentina Manea  *    corresponds to usb_unlink_urb()
11196c27377SValentina Manea  *    (client to server)
11296c27377SValentina Manea  *
11396c27377SValentina Manea  *  - USBIP_RET_UNLINK: the result of USBIP_CMD_UNLINK
11496c27377SValentina Manea  *    (server to client)
11596c27377SValentina Manea  *
11696c27377SValentina Manea  */
11796c27377SValentina Manea #define USBIP_CMD_SUBMIT	0x0001
11896c27377SValentina Manea #define USBIP_CMD_UNLINK	0x0002
11996c27377SValentina Manea #define USBIP_RET_SUBMIT	0x0003
12096c27377SValentina Manea #define USBIP_RET_UNLINK	0x0004
12196c27377SValentina Manea 
12296c27377SValentina Manea #define USBIP_DIR_OUT	0x00
12396c27377SValentina Manea #define USBIP_DIR_IN	0x01
12496c27377SValentina Manea 
125c409ca3bSMalte Leip /*
126c409ca3bSMalte Leip  * Arbitrary limit for the maximum number of isochronous packets in an URB,
127c409ca3bSMalte Leip  * compare for example the uhci_submit_isochronous function in
128c409ca3bSMalte Leip  * drivers/usb/host/uhci-q.c
129c409ca3bSMalte Leip  */
130c409ca3bSMalte Leip #define USBIP_MAX_ISO_PACKETS 1024
131c409ca3bSMalte Leip 
13296c27377SValentina Manea /**
13396c27377SValentina Manea  * struct usbip_header_basic - data pertinent to every request
13496c27377SValentina Manea  * @command: the usbip request type
13596c27377SValentina Manea  * @seqnum: sequential number that identifies requests; incremented per
13696c27377SValentina Manea  *	    connection
13796c27377SValentina Manea  * @devid: specifies a remote USB device uniquely instead of busnum and devnum;
13896c27377SValentina Manea  *	   in the stub driver, this value is ((busnum << 16) | devnum)
13996c27377SValentina Manea  * @direction: direction of the transfer
14096c27377SValentina Manea  * @ep: endpoint number
14196c27377SValentina Manea  */
14296c27377SValentina Manea struct usbip_header_basic {
14396c27377SValentina Manea 	__u32 command;
14496c27377SValentina Manea 	__u32 seqnum;
14596c27377SValentina Manea 	__u32 devid;
14696c27377SValentina Manea 	__u32 direction;
14796c27377SValentina Manea 	__u32 ep;
14896c27377SValentina Manea } __packed;
14996c27377SValentina Manea 
15096c27377SValentina Manea /**
15196c27377SValentina Manea  * struct usbip_header_cmd_submit - USBIP_CMD_SUBMIT packet header
15296c27377SValentina Manea  * @transfer_flags: URB flags
15396c27377SValentina Manea  * @transfer_buffer_length: the data size for (in) or (out) transfer
15496c27377SValentina Manea  * @start_frame: initial frame for isochronous or interrupt transfers
15596c27377SValentina Manea  * @number_of_packets: number of isochronous packets
15696c27377SValentina Manea  * @interval: maximum time for the request on the server-side host controller
15796c27377SValentina Manea  * @setup: setup data for a control request
15896c27377SValentina Manea  */
15996c27377SValentina Manea struct usbip_header_cmd_submit {
16096c27377SValentina Manea 	__u32 transfer_flags;
16196c27377SValentina Manea 	__s32 transfer_buffer_length;
16296c27377SValentina Manea 
16396c27377SValentina Manea 	/* it is difficult for usbip to sync frames (reserved only?) */
16496c27377SValentina Manea 	__s32 start_frame;
16596c27377SValentina Manea 	__s32 number_of_packets;
16696c27377SValentina Manea 	__s32 interval;
16796c27377SValentina Manea 
16896c27377SValentina Manea 	unsigned char setup[8];
16996c27377SValentina Manea } __packed;
17096c27377SValentina Manea 
17196c27377SValentina Manea /**
17296c27377SValentina Manea  * struct usbip_header_ret_submit - USBIP_RET_SUBMIT packet header
17396c27377SValentina Manea  * @status: return status of a non-iso request
17496c27377SValentina Manea  * @actual_length: number of bytes transferred
17596c27377SValentina Manea  * @start_frame: initial frame for isochronous or interrupt transfers
17696c27377SValentina Manea  * @number_of_packets: number of isochronous packets
17796c27377SValentina Manea  * @error_count: number of errors for isochronous transfers
17896c27377SValentina Manea  */
17996c27377SValentina Manea struct usbip_header_ret_submit {
18096c27377SValentina Manea 	__s32 status;
18196c27377SValentina Manea 	__s32 actual_length;
18296c27377SValentina Manea 	__s32 start_frame;
18396c27377SValentina Manea 	__s32 number_of_packets;
18496c27377SValentina Manea 	__s32 error_count;
18596c27377SValentina Manea } __packed;
18696c27377SValentina Manea 
18796c27377SValentina Manea /**
18896c27377SValentina Manea  * struct usbip_header_cmd_unlink - USBIP_CMD_UNLINK packet header
18996c27377SValentina Manea  * @seqnum: the URB seqnum to unlink
19096c27377SValentina Manea  */
19196c27377SValentina Manea struct usbip_header_cmd_unlink {
19296c27377SValentina Manea 	__u32 seqnum;
19396c27377SValentina Manea } __packed;
19496c27377SValentina Manea 
19596c27377SValentina Manea /**
19696c27377SValentina Manea  * struct usbip_header_ret_unlink - USBIP_RET_UNLINK packet header
19796c27377SValentina Manea  * @status: return status of the request
19896c27377SValentina Manea  */
19996c27377SValentina Manea struct usbip_header_ret_unlink {
20096c27377SValentina Manea 	__s32 status;
20196c27377SValentina Manea } __packed;
20296c27377SValentina Manea 
20396c27377SValentina Manea /**
20496c27377SValentina Manea  * struct usbip_header - common header for all usbip packets
20596c27377SValentina Manea  * @base: the basic header
20696c27377SValentina Manea  * @u: packet type dependent header
20796c27377SValentina Manea  */
20896c27377SValentina Manea struct usbip_header {
20996c27377SValentina Manea 	struct usbip_header_basic base;
21096c27377SValentina Manea 
21196c27377SValentina Manea 	union {
21296c27377SValentina Manea 		struct usbip_header_cmd_submit	cmd_submit;
21396c27377SValentina Manea 		struct usbip_header_ret_submit	ret_submit;
21496c27377SValentina Manea 		struct usbip_header_cmd_unlink	cmd_unlink;
21596c27377SValentina Manea 		struct usbip_header_ret_unlink	ret_unlink;
21696c27377SValentina Manea 	} u;
21796c27377SValentina Manea } __packed;
21896c27377SValentina Manea 
21996c27377SValentina Manea /*
22096c27377SValentina Manea  * This is the same as usb_iso_packet_descriptor but packed for pdu.
22196c27377SValentina Manea  */
22296c27377SValentina Manea struct usbip_iso_packet_descriptor {
22396c27377SValentina Manea 	__u32 offset;
22496c27377SValentina Manea 	__u32 length;			/* expected length */
22596c27377SValentina Manea 	__u32 actual_length;
22696c27377SValentina Manea 	__u32 status;
22796c27377SValentina Manea } __packed;
22896c27377SValentina Manea 
22996c27377SValentina Manea enum usbip_side {
23096c27377SValentina Manea 	USBIP_VHCI,
23196c27377SValentina Manea 	USBIP_STUB,
232c7af4c22SIgor Kotrasinski 	USBIP_VUDC,
23396c27377SValentina Manea };
23496c27377SValentina Manea 
23596c27377SValentina Manea /* event handler */
23696c27377SValentina Manea #define USBIP_EH_SHUTDOWN	(1 << 0)
23796c27377SValentina Manea #define USBIP_EH_BYE		(1 << 1)
23896c27377SValentina Manea #define USBIP_EH_RESET		(1 << 2)
23996c27377SValentina Manea #define USBIP_EH_UNUSABLE	(1 << 3)
24096c27377SValentina Manea 
241134a9265SAlexander Popov #define	SDEV_EVENT_REMOVED	(USBIP_EH_SHUTDOWN | USBIP_EH_BYE)
24296c27377SValentina Manea #define	SDEV_EVENT_DOWN		(USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
24396c27377SValentina Manea #define	SDEV_EVENT_ERROR_TCP	(USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
24496c27377SValentina Manea #define	SDEV_EVENT_ERROR_SUBMIT	(USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
24596c27377SValentina Manea #define	SDEV_EVENT_ERROR_MALLOC	(USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE)
24696c27377SValentina Manea 
247c7af4c22SIgor Kotrasinski #define VUDC_EVENT_REMOVED   (USBIP_EH_SHUTDOWN | USBIP_EH_RESET | USBIP_EH_BYE)
248c7af4c22SIgor Kotrasinski #define	VUDC_EVENT_DOWN		(USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
249c7af4c22SIgor Kotrasinski #define	VUDC_EVENT_ERROR_TCP	(USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
250c7af4c22SIgor Kotrasinski /* catastrophic emulated usb error */
251c7af4c22SIgor Kotrasinski #define	VUDC_EVENT_ERROR_USB	(USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE)
252c7af4c22SIgor Kotrasinski #define	VUDC_EVENT_ERROR_MALLOC	(USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE)
253c7af4c22SIgor Kotrasinski 
2549020a7efSShuah Khan #define	VDEV_EVENT_REMOVED (USBIP_EH_SHUTDOWN | USBIP_EH_RESET | USBIP_EH_BYE)
25596c27377SValentina Manea #define	VDEV_EVENT_DOWN		(USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
25696c27377SValentina Manea #define	VDEV_EVENT_ERROR_TCP	(USBIP_EH_SHUTDOWN | USBIP_EH_RESET)
25796c27377SValentina Manea #define	VDEV_EVENT_ERROR_MALLOC	(USBIP_EH_SHUTDOWN | USBIP_EH_UNUSABLE)
25896c27377SValentina Manea 
25996c27377SValentina Manea /* a common structure for stub_device and vhci_device */
26096c27377SValentina Manea struct usbip_device {
26196c27377SValentina Manea 	enum usbip_side side;
26296c27377SValentina Manea 	enum usbip_device_status status;
26396c27377SValentina Manea 
26496c27377SValentina Manea 	/* lock for status */
26596c27377SValentina Manea 	spinlock_t lock;
26696c27377SValentina Manea 
267*4e9c93afSShuah Khan 	/* mutex for synchronizing sysfs store paths */
268*4e9c93afSShuah Khan 	struct mutex sysfs_lock;
269*4e9c93afSShuah Khan 
2702f2d0088SShuah Khan 	int sockfd;
27196c27377SValentina Manea 	struct socket *tcp_socket;
27296c27377SValentina Manea 
27396c27377SValentina Manea 	struct task_struct *tcp_rx;
27496c27377SValentina Manea 	struct task_struct *tcp_tx;
27596c27377SValentina Manea 
27696c27377SValentina Manea 	unsigned long event;
27796c27377SValentina Manea 	wait_queue_head_t eh_waitq;
27896c27377SValentina Manea 
27996c27377SValentina Manea 	struct eh_ops {
28096c27377SValentina Manea 		void (*shutdown)(struct usbip_device *);
28196c27377SValentina Manea 		void (*reset)(struct usbip_device *);
28296c27377SValentina Manea 		void (*unusable)(struct usbip_device *);
28396c27377SValentina Manea 	} eh_ops;
284894f1f4fSNazime Hande Harputluoglu 
285894f1f4fSNazime Hande Harputluoglu #ifdef CONFIG_KCOV
286894f1f4fSNazime Hande Harputluoglu 	u64 kcov_handle;
287894f1f4fSNazime Hande Harputluoglu #endif
28896c27377SValentina Manea };
28996c27377SValentina Manea 
29096c27377SValentina Manea #define kthread_get_run(threadfn, data, namefmt, ...)			   \
29196c27377SValentina Manea ({									   \
29296c27377SValentina Manea 	struct task_struct *__k						   \
29396c27377SValentina Manea 		= kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
29496c27377SValentina Manea 	if (!IS_ERR(__k)) {						   \
29596c27377SValentina Manea 		get_task_struct(__k);					   \
29696c27377SValentina Manea 		wake_up_process(__k);					   \
29796c27377SValentina Manea 	}								   \
29896c27377SValentina Manea 	__k;								   \
29996c27377SValentina Manea })
30096c27377SValentina Manea 
30196c27377SValentina Manea /* usbip_common.c */
30296c27377SValentina Manea void usbip_dump_urb(struct urb *purb);
30396c27377SValentina Manea void usbip_dump_header(struct usbip_header *pdu);
30496c27377SValentina Manea 
30596c27377SValentina Manea int usbip_recv(struct socket *sock, void *buf, int size);
30696c27377SValentina Manea 
30796c27377SValentina Manea void usbip_pack_pdu(struct usbip_header *pdu, struct urb *urb, int cmd,
30896c27377SValentina Manea 		    int pack);
30996c27377SValentina Manea void usbip_header_correct_endian(struct usbip_header *pdu, int send);
31096c27377SValentina Manea 
31196c27377SValentina Manea struct usbip_iso_packet_descriptor*
31296c27377SValentina Manea usbip_alloc_iso_desc_pdu(struct urb *urb, ssize_t *bufflen);
31396c27377SValentina Manea 
31496c27377SValentina Manea /* some members of urb must be substituted before. */
31596c27377SValentina Manea int usbip_recv_iso(struct usbip_device *ud, struct urb *urb);
31696c27377SValentina Manea void usbip_pad_iso(struct usbip_device *ud, struct urb *urb);
31796c27377SValentina Manea int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb);
31896c27377SValentina Manea 
31996c27377SValentina Manea /* usbip_event.c */
320bb7871adSNobuo Iwata int usbip_init_eh(void);
321bb7871adSNobuo Iwata void usbip_finish_eh(void);
32296c27377SValentina Manea int usbip_start_eh(struct usbip_device *ud);
32396c27377SValentina Manea void usbip_stop_eh(struct usbip_device *ud);
32496c27377SValentina Manea void usbip_event_add(struct usbip_device *ud, unsigned long event);
32596c27377SValentina Manea int usbip_event_happened(struct usbip_device *ud);
326bb7871adSNobuo Iwata int usbip_in_eh(struct task_struct *task);
32796c27377SValentina Manea 
interface_to_busnum(struct usb_interface * interface)32896c27377SValentina Manea static inline int interface_to_busnum(struct usb_interface *interface)
32996c27377SValentina Manea {
33096c27377SValentina Manea 	struct usb_device *udev = interface_to_usbdev(interface);
33196c27377SValentina Manea 
33296c27377SValentina Manea 	return udev->bus->busnum;
33396c27377SValentina Manea }
33496c27377SValentina Manea 
interface_to_devnum(struct usb_interface * interface)33596c27377SValentina Manea static inline int interface_to_devnum(struct usb_interface *interface)
33696c27377SValentina Manea {
33796c27377SValentina Manea 	struct usb_device *udev = interface_to_usbdev(interface);
33896c27377SValentina Manea 
33996c27377SValentina Manea 	return udev->devnum;
34096c27377SValentina Manea }
34196c27377SValentina Manea 
342894f1f4fSNazime Hande Harputluoglu #ifdef CONFIG_KCOV
343894f1f4fSNazime Hande Harputluoglu 
usbip_kcov_handle_init(struct usbip_device * ud)344894f1f4fSNazime Hande Harputluoglu static inline void usbip_kcov_handle_init(struct usbip_device *ud)
345894f1f4fSNazime Hande Harputluoglu {
346894f1f4fSNazime Hande Harputluoglu 	ud->kcov_handle = kcov_common_handle();
347894f1f4fSNazime Hande Harputluoglu }
348894f1f4fSNazime Hande Harputluoglu 
usbip_kcov_remote_start(struct usbip_device * ud)349894f1f4fSNazime Hande Harputluoglu static inline void usbip_kcov_remote_start(struct usbip_device *ud)
350894f1f4fSNazime Hande Harputluoglu {
351894f1f4fSNazime Hande Harputluoglu 	kcov_remote_start_common(ud->kcov_handle);
352894f1f4fSNazime Hande Harputluoglu }
353894f1f4fSNazime Hande Harputluoglu 
usbip_kcov_remote_stop(void)354894f1f4fSNazime Hande Harputluoglu static inline void usbip_kcov_remote_stop(void)
355894f1f4fSNazime Hande Harputluoglu {
356894f1f4fSNazime Hande Harputluoglu 	kcov_remote_stop();
357894f1f4fSNazime Hande Harputluoglu }
358894f1f4fSNazime Hande Harputluoglu 
359894f1f4fSNazime Hande Harputluoglu #else /* CONFIG_KCOV */
360894f1f4fSNazime Hande Harputluoglu 
usbip_kcov_handle_init(struct usbip_device * ud)361894f1f4fSNazime Hande Harputluoglu static inline void usbip_kcov_handle_init(struct usbip_device *ud) { }
usbip_kcov_remote_start(struct usbip_device * ud)362894f1f4fSNazime Hande Harputluoglu static inline void usbip_kcov_remote_start(struct usbip_device *ud) { }
usbip_kcov_remote_stop(void)363894f1f4fSNazime Hande Harputluoglu static inline void usbip_kcov_remote_stop(void) { }
364894f1f4fSNazime Hande Harputluoglu 
365894f1f4fSNazime Hande Harputluoglu #endif /* CONFIG_KCOV */
366894f1f4fSNazime Hande Harputluoglu 
36796c27377SValentina Manea #endif /* __USBIP_COMMON_H */
368