2017-11-03 18:28:30 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-07-10 04:56:51 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2003-2008 Takahiro Hirofuchi
|
|
|
|
*/
|
|
|
|
|
2011-08-22 14:53:28 +08:00
|
|
|
#ifndef __USBIP_STUB_H
|
|
|
|
#define __USBIP_STUB_H
|
|
|
|
|
2008-07-10 04:56:51 +08:00
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/slab.h>
|
2011-05-12 13:33:43 +08:00
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/wait.h>
|
2008-07-10 04:56:51 +08:00
|
|
|
|
2010-07-27 18:39:30 +08:00
|
|
|
#define STUB_BUSID_OTHER 0
|
|
|
|
#define STUB_BUSID_REMOV 1
|
|
|
|
#define STUB_BUSID_ADDED 2
|
|
|
|
#define STUB_BUSID_ALLOC 3
|
|
|
|
|
2008-07-10 04:56:51 +08:00
|
|
|
struct stub_device {
|
2011-01-12 21:01:59 +08:00
|
|
|
struct usb_device *udev;
|
2008-07-10 04:56:51 +08:00
|
|
|
|
|
|
|
struct usbip_device ud;
|
|
|
|
__u32 devid;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* stub_priv preserves private data of each urb.
|
|
|
|
* It is allocated as stub_priv_cache and assigned to urb->context.
|
|
|
|
*
|
|
|
|
* stub_priv is always linked to any one of 3 lists;
|
|
|
|
* priv_init: linked to this until the comletion of a urb.
|
|
|
|
* priv_tx : linked to this after the completion of a urb.
|
|
|
|
* priv_free: linked to this after the sending of the result.
|
|
|
|
*
|
|
|
|
* Any of these list operations should be locked by priv_lock.
|
|
|
|
*/
|
|
|
|
spinlock_t priv_lock;
|
|
|
|
struct list_head priv_init;
|
|
|
|
struct list_head priv_tx;
|
|
|
|
struct list_head priv_free;
|
|
|
|
|
|
|
|
/* see comments for unlinking in stub_rx.c */
|
|
|
|
struct list_head unlink_tx;
|
|
|
|
struct list_head unlink_free;
|
|
|
|
|
|
|
|
wait_queue_head_t tx_waitq;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* private data into urb->priv */
|
|
|
|
struct stub_priv {
|
|
|
|
unsigned long seqnum;
|
|
|
|
struct list_head list;
|
|
|
|
struct stub_device *sdev;
|
|
|
|
struct urb *urb;
|
|
|
|
|
|
|
|
int unlinking;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct stub_unlink {
|
|
|
|
unsigned long seqnum;
|
|
|
|
struct list_head list;
|
|
|
|
__u32 status;
|
|
|
|
};
|
|
|
|
|
2011-05-27 16:44:12 +08:00
|
|
|
/* same as SYSFS_BUS_ID_SIZE */
|
|
|
|
#define BUSID_SIZE 32
|
2011-05-20 12:36:56 +08:00
|
|
|
|
2010-07-27 18:39:30 +08:00
|
|
|
struct bus_id_priv {
|
|
|
|
char name[BUSID_SIZE];
|
|
|
|
char status;
|
|
|
|
int interf_count;
|
|
|
|
struct stub_device *sdev;
|
2014-03-08 20:53:33 +08:00
|
|
|
struct usb_device *udev;
|
2010-07-27 18:39:30 +08:00
|
|
|
char shutdown_busid;
|
2018-05-15 10:49:58 +08:00
|
|
|
spinlock_t busid_lock;
|
2010-07-27 18:39:30 +08:00
|
|
|
};
|
2008-07-10 04:56:51 +08:00
|
|
|
|
2011-05-11 16:54:22 +08:00
|
|
|
/* stub_priv is allocated from stub_priv_cache */
|
2008-07-10 04:56:51 +08:00
|
|
|
extern struct kmem_cache *stub_priv_cache;
|
|
|
|
|
|
|
|
/* stub_dev.c */
|
2014-01-24 05:12:29 +08:00
|
|
|
extern struct usb_device_driver stub_driver;
|
2008-07-10 04:56:51 +08:00
|
|
|
|
|
|
|
/* stub_main.c */
|
2010-07-27 18:39:30 +08:00
|
|
|
struct bus_id_priv *get_busid_priv(const char *busid);
|
2018-05-15 10:49:58 +08:00
|
|
|
void put_busid_priv(struct bus_id_priv *bid);
|
2010-07-27 18:39:30 +08:00
|
|
|
int del_match_busid(char *busid);
|
2008-07-10 04:56:51 +08:00
|
|
|
void stub_device_cleanup_urbs(struct stub_device *sdev);
|
2011-05-11 16:54:22 +08:00
|
|
|
|
|
|
|
/* stub_rx.c */
|
|
|
|
int stub_rx_loop(void *data);
|
|
|
|
|
|
|
|
/* stub_tx.c */
|
|
|
|
void stub_enqueue_ret_unlink(struct stub_device *sdev, __u32 seqnum,
|
|
|
|
__u32 status);
|
|
|
|
void stub_complete(struct urb *urb);
|
|
|
|
int stub_tx_loop(void *data);
|
2011-08-22 14:53:28 +08:00
|
|
|
|
|
|
|
#endif /* __USBIP_STUB_H */
|