18#ifndef __VSF_USBIP_DCD_H__
19#define __VSF_USBIP_DCD_H__
25#if VSF_USE_USB_DEVICE == ENABLED && VSF_USBD_USE_DCD_USBIP == ENABLED
31#if defined(__VSF_USBIP_DCD_CLASS_IMPLEMENT)
32# define __VSF_CLASS_IMPLEMENT__
43#define VSF_USBIP_DCD_CFG_BACKEND_WIN 1
44#define VSF_USBIP_DCD_CFG_BACKEND_VSFSOCK 2
45#define VSF_USBIP_DCD_CFG_BACKEND_LWIP 3
47#ifndef VSF_USBIP_DCD_CFG_BACKEND
52# define VSF_USBIP_DCD_CFG_BACKEND VSF_USBIP_DCD_CFG_BACKEND_WIN
53# elif VSF_USE_LWIP == ENABLED
54# define VSF_USBIP_DCD_CFG_BACKEND VSF_USBIP_DCD_CFG_BACKEND_LWIP
55# elif VSF_USE_TCPIP == ENABLED
56# define VSF_USBIP_DCD_CFG_BACKEND VSF_USBIP_DCD_CFG_BACKEND_VSFSOCK
60#ifndef VSF_USBIP_DCD_CFG_PATH
61# define VSF_USBIP_DCD_CFG_PATH "/vsf/usbd/0"
66#define vsf_usb_dc_from_usbip_ip(__n, __obj, __drv_name) \
67 __USB_DC_FROM_IP(__n, (__obj), __drv_name, vk_usbip_usbd)
69#if VSF_USBIP_SERVER_CFG_DEBUG == ENABLED
70# define __vk_usbip_server_trace(...) \
71 vsf_trace_debug("usbip_server: " __VA_ARGS__)
72# define __vk_usbip_server_trace_buffer(...) \
73 vsf_trace_buffer(VSF_TRACE_DEBUG, __VA_ARGS__, VSF_TRACE_DF_DEFAULT)
75# define __vk_usbip_server_trace(...)
76# define __vk_usbip_server_trace_buffer(...)
79#if VSF_USBIP_SERVER_CFG_DEBUG_TRAFFIC == ENABLED
80# define __vk_usbip_server_trace_rx(__buffer, __size) \
82 __vk_usbip_server_trace("recv %d bytes" VSF_TRACE_CFG_LINEEND, __size);\
83 __vk_usbip_server_trace_buffer(__buffer, __size); \
86# define __vk_usbip_server_trace_tx(__buffer, __size) \
88 __vk_usbip_server_trace("send %d bytes" VSF_TRACE_CFG_LINEEND, __size);\
89 __vk_usbip_server_trace_buffer(__buffer, __size); \
92# define __vk_usbip_server_trace_rx(__buffer, __size)
93# define __vk_usbip_server_trace_tx(__buffer, __size)
96#if VSF_USBIP_SERVER_CFG_DEBUG_URB == ENABLED
97# define __vk_usbip_server_trace_urb_submit(__urb) \
99 __vk_usbip_server_trace("submit urb%d %s%d %d bytes" VSF_TRACE_CFG_LINEEND,\
100 (__urb)->req.seqnum, \
101 (__urb)->req.direction ? "IN" : "OUT", \
103 (__urb)->req.transfer_length); \
104 if (!(__urb)->req.ep) { \
105 __vk_usbip_server_trace_buffer(&((__urb)->req.setup), 8); \
107 if (!(__urb)->req.direction && (__urb)->req.transfer_length) { \
108 __vk_usbip_server_trace_buffer((__urb)->dynmem.buffer, (__urb)->req.transfer_length);\
112# define __vk_usbip_server_trace_urb_done(__urb) \
114 __vk_usbip_server_trace("done urb%d %s%d " VSF_TRACE_CFG_LINEEND, \
115 (__urb)->req.seqnum, \
116 (__urb)->req.direction ? "IN" : "OUT", \
118 uint_fast32_t actual_length = be32_to_cpu((__urb)->rep.actual_length);\
119 if ((__urb)->req.direction && actual_length) { \
120 __vk_usbip_server_trace_buffer((__urb)->dynmem.buffer, actual_length);\
124# define __vk_usbip_server_trace_urb_unlink(__urb) \
126 __vk_usbip_server_trace("unlink urb%d %s%d " VSF_TRACE_CFG_LINEEND, \
127 (__urb)->req.seqnum, \
128 (__urb)->req.direction ? "IN" : "OUT", \
132# define __vk_usbip_server_trace_urb_submit(__urb)
133# define __vk_usbip_server_trace_urb_done(__urb)
134# define __vk_usbip_server_trace_urb_unlink(__urb)
184#if defined(__VSF_USBIP_DCD_CLASS_IMPLEMENT_BACKEND__) \
185 || defined(__VSF_USBIP_DCD_CLASS_IMPLEMENT)
187# undef __VSF_USBIP_DCD_CLASS_IMPLEMENT_BACKEND__
191 VSF_USBIP_SERVER_EVT_BACKEND_INIT_DONE = VSF_USBIP_SERVER_EVT + 0,
192 VSF_USBIP_SERVER_EVT_BACKEND_CONNECTED = VSF_USBIP_SERVER_EVT + 1,
193 VSF_USBIP_SERVER_EVT_BACKEND_DISCONNECTED = VSF_USBIP_SERVER_EVT + 2,
194 VSF_USBIP_SERVER_EVT_BACKEND_RECV_DONE = VSF_USBIP_SERVER_EVT + 3,
195 VSF_USBIP_SERVER_EVT_BACKEND_SEND_DONE = VSF_USBIP_SERVER_EVT + 4,
200typedef struct vk_usbip_rep_ifs_t {
207typedef struct vk_usbip_rep_dev_t {
220 vk_usbip_rep_ifs_t ifs[16];
223typedef enum vk_usbip_cmd_t {
224 USBIP_CMD_INVALID = 0x00000000,
225 USBIP_CMD_SUBMIT = 0x00000001,
226 USBIP_CMD_UNLINK = 0x00000002,
227 USBIP_RET_SUBMIT = 0x00000003,
228 USBIP_RET_UNLINK = 0x00000004,
230 USBIP_REQ_DEVLIST = 0x8005,
231 USBIP_REP_DEVLIST = 0x8005,
232 USBIP_REQ_IMPORT = 0x8003,
233 USBIP_REP_IMPORT = 0x8003,
236typedef struct vk_usbip_op_common_t {
243typedef struct vk_usbip_req_devlist_t {
244 implement(vk_usbip_op_common_t)
251typedef struct vk_usbip_rep_devlist_t {
252 implement(vk_usbip_op_common_t)
257typedef struct vk_usbip_req_import_t {
258 implement(vk_usbip_op_common_t)
265typedef struct vk_usbip_rep_import_t {
266 implement(vk_usbip_op_common_t)
272typedef struct vk_usbip_req_submit_t {
289typedef struct vk_usbip_rep_submit_t {
305typedef struct vk_usbip_req_unlink_t {
317typedef struct vk_usbip_rep_unlink_t {
326typedef struct vk_usbip_urb_t {
329 vk_usbip_req_submit_t req;
331 vk_usbip_rep_submit_t rep;
332 vk_usbip_rep_unlink_t
unlink;
339 VSF_USBIP_URB_IDLE = 0,
340 VSF_USBIP_URB_QUEUED,
341 VSF_USBIP_URB_COMITTED,
346typedef struct vk_usbip_server_t {
353 VSF_USBIP_SERVER_REQ_COMMAND,
354 VSF_USBIP_SERVER_REQ_PARAM,
355 VSF_USBIP_SERVER_REQ_DATA,
357 vk_usbip_cmd_t command;
360 VSF_USBIP_SERVER_REP_DONE = 0,
361 VSF_USBIP_SERVER_REP_REPLY = 1,
362 VSF_USBIP_SERVER_REP_PARAM = 2,
363 VSF_USBIP_SERVER_REP_DATA = 3,
366 VSF_USBIP_SERVER_REP_DEVLIST_PATH = 2,
367 VSF_USBIP_SERVER_REP_DEVLIST_BUSID = 3,
368 VSF_USBIP_SERVER_REP_DEVLIST_DEV = 4,
369 VSF_USBIP_SERVER_REP_DEVLIST_CFG = 5,
372 VSF_USBIP_SERVER_REP_IMPORT_PATH = VSF_USBIP_SERVER_REP_DEVLIST_PATH,
373 VSF_USBIP_SERVER_REP_IMPORT_BUSID = VSF_USBIP_SERVER_REP_DEVLIST_BUSID,
374 VSF_USBIP_SERVER_REP_IMPORT_DEV = VSF_USBIP_SERVER_REP_DEVLIST_DEV,
376 vk_usbip_cmd_t reply;
385 vk_usbip_req_devlist_t devlist;
386 vk_usbip_req_import_t
import;
387 vk_usbip_req_submit_t submit;
388 vk_usbip_req_unlink_t
unlink;
392 vk_usbip_op_common_t common;
393 vk_usbip_rep_devlist_t devlist;
394 vk_usbip_rep_import_t
import;
395 vk_usbip_rep_unlink_t
unlink;
399 vk_usbip_rep_dev_t dev;
401 vk_usbip_urb_t *cur_urb;
446#undef __VSF_USBIP_DCD_CLASS_IMPLEMENT
vsf_err_t
Definition __type.h:42
Definition vsf_usbip_dcd.h:158
unsigned short uint16_t
Definition lvgl.h:41
unsigned int uint32_t
Definition lvgl.h:43
unsigned char uint8_t
Definition lvgl.h:40
#define vsf_class(__name)
Definition ooc_class.h:48
unsigned char uint_fast8_t
Definition stdint.h:23
unsigned int uint_fast32_t
Definition stdint.h:27
unsigned short uint_fast16_t
Definition stdint.h:25
Definition usb_common.h:85
Definition vsf_template_usb.h:316
Definition vsf_usbip_dcd.h:143
vsf_mem_t mem
Definition vsf_usbip_dcd.h:151
bool zlp
Definition vsf_usbip_dcd.h:153
uint32_t size
Definition vsf_usbip_dcd.h:152
uint16_t size
Definition vsf_usbip_dcd.h:144
vsf_dlist_t urb_list
Definition vsf_usbip_dcd.h:149
usb_ep_type_t type
Definition vsf_usbip_dcd.h:145
bool is_stalled
Definition vsf_usbip_dcd.h:146
struct vk_usbip_dcd_ep_t::@209 transfer
bool pending
Definition vsf_usbip_dcd.h:154
uint8_t ep
Definition vsf_usbip_dcd.h:147
Definition vsf_usbip_dcd.h:139
uint16_t port
Definition vsf_usbip_dcd.h:140
Definition vsf_list.h:888
Definition vsf_list.h:883
Definition vsf_utilities.h:51
#define unlink
Definition unistd.h:116
vk_av_control_type_t type
Definition vsf_audio.h:170
@ VSF_EVT_USER
Definition vsf_eda.h:621
uint32_t size
Definition vsf_memfs.h:50
uint8_t state
Definition vsf_msg_tree.h:247
struct vk_romfs_header_t VSF_CAL_PACKED
usb_ep_type_t
Definition vsf_template_usb.h:277
void(* usb_dc_evthandler_t)(void *param, usb_evt_t evt, uint_fast8_t value)
Definition vsf_template_usb.h:309
uint8_t status
Definition vsf_tgui.h:139
vsf_err_t vk_usbip_usbd_ep_transaction_enable_out(vk_usbip_dcd_t *usbd, uint_fast8_t ep)
Definition vsf_usbip_dcd.c:735
uint_fast32_t vk_usbip_usbd_ep_get_data_size(vk_usbip_dcd_t *usbd, uint_fast8_t ep)
Definition vsf_usbip_dcd.c:724
vsf_err_t vk_usbip_usbd_init(vk_usbip_dcd_t *usbd, usb_dc_cfg_t *cfg)
Definition vsf_usbip_dcd.c:605
uint_fast16_t vk_usbip_usbd_ep_get_size(vk_usbip_dcd_t *usbd, uint_fast8_t ep)
Definition vsf_usbip_dcd.c:698
void vk_usbip_usbd_connect(vk_usbip_dcd_t *usbd)
Definition vsf_usbip_dcd.c:627
uint_fast8_t vk_usbip_usbd_get_mframe_number(vk_usbip_dcd_t *usbd)
Definition vsf_usbip_dcd.c:662
uint_fast8_t vk_usbip_usbd_get_address(vk_usbip_dcd_t *usbd)
Definition vsf_usbip_dcd.c:652
void vk_usbip_usbd_set_address(vk_usbip_dcd_t *usbd, uint_fast8_t addr)
Definition vsf_usbip_dcd.c:647
void vk_usbip_usbd_wakeup(vk_usbip_dcd_t *usbd)
Definition vsf_usbip_dcd.c:643
vsf_err_t vk_usbip_usbd_ep_transaction_set_data_size(vk_usbip_dcd_t *usbd, uint_fast8_t ep, uint_fast16_t size)
Definition vsf_usbip_dcd.c:740
vsf_err_t vk_usbip_usbd_ep_transfer_send(vk_usbip_dcd_t *usbd, uint_fast8_t ep, uint8_t *buffer, uint_fast32_t size, bool zlp)
Definition vsf_usbip_dcd.c:762
vsf_err_t vk_usbip_usbd_ep_set_stall(vk_usbip_dcd_t *usbd, uint_fast8_t ep)
Definition vsf_usbip_dcd.c:704
vsf_err_t vk_usbip_usbd_ep_clear_stall(vk_usbip_dcd_t *usbd, uint_fast8_t ep)
Definition vsf_usbip_dcd.c:717
void vk_usbip_usbd_irq(vk_usbip_dcd_t *usbd)
Definition vsf_usbip_dcd.c:776
vsf_err_t vk_usbip_usbd_ep_transaction_write_buffer(vk_usbip_dcd_t *usbd, uint_fast8_t ep, uint8_t *buffer, uint_fast16_t size)
Definition vsf_usbip_dcd.c:745
void vk_usbip_usbd_get_setup(vk_usbip_dcd_t *usbd, uint8_t *buffer)
Definition vsf_usbip_dcd.c:667
void vk_usbip_usbd_fini(vk_usbip_dcd_t *usbd)
Definition vsf_usbip_dcd.c:616
uint_fast16_t vk_usbip_usbd_get_frame_number(vk_usbip_dcd_t *usbd)
Definition vsf_usbip_dcd.c:657
uint_fast8_t vk_usbip_usbd_ep_get_feature(vk_usbip_dcd_t *usbd, uint_fast8_t ep, uint_fast8_t feature)
Definition vsf_usbip_dcd.c:684
vsf_err_t vk_usbip_usbd_ep_add(vk_usbip_dcd_t *usbd, uint_fast8_t ep, usb_ep_type_t type, uint_fast16_t size)
Definition vsf_usbip_dcd.c:689
bool vk_usbip_usbd_ep_is_stalled(vk_usbip_dcd_t *usbd, uint_fast8_t ep)
Definition vsf_usbip_dcd.c:711
void vk_usbip_usbd_status_stage(vk_usbip_dcd_t *usbd, bool is_in)
Definition vsf_usbip_dcd.c:672
void vk_usbip_usbd_disconnect(vk_usbip_dcd_t *usbd)
Definition vsf_usbip_dcd.c:635
void vk_usbip_usbd_reset(vk_usbip_dcd_t *usbd, usb_dc_cfg_t *cfg)
Definition vsf_usbip_dcd.c:621
vsf_err_t vk_usbip_usbd_ep_transfer_recv(vk_usbip_dcd_t *usbd, uint_fast8_t ep, uint8_t *buffer, uint_fast32_t size)
Definition vsf_usbip_dcd.c:750
vsf_err_t vk_usbip_usbd_ep_transaction_read_buffer(vk_usbip_dcd_t *usbd, uint_fast8_t ep, uint8_t *buffer, uint_fast16_t size)
Definition vsf_usbip_dcd.c:730