1 /*
2  * Copyright (c) 2024, sakumisu
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #ifndef USBH_CDC_NCM_H
7 #define USBH_CDC_NCM_H
8 
9 #include "usb_cdc.h"
10 
11 struct usbh_cdc_ncm {
12     struct usbh_hubport *hport;
13     struct usb_endpoint_descriptor *bulkin;  /* Bulk IN endpoint */
14     struct usb_endpoint_descriptor *bulkout; /* Bulk OUT endpoint */
15     struct usb_endpoint_descriptor *intin;   /* Interrupt IN endpoint */
16     struct usbh_urb bulkout_urb;             /* Bulk out endpoint */
17     struct usbh_urb bulkin_urb;              /* Bulk IN endpoint */
18     struct usbh_urb intin_urb;               /* Interrupt IN endpoint */
19 
20     uint8_t ctrl_intf; /* Control interface number */
21     uint8_t data_intf; /* Data interface number */
22     uint8_t minor;
23 
24     struct cdc_ncm_ntb_parameters ntb_param;
25     uint16_t bulkin_sequence;
26     uint16_t bulkout_sequence;
27 
28     uint8_t mac[6];
29     bool connect_status;
30     uint16_t max_segment_size;
31     uint32_t speed[2];
32 
33     void *user_data;
34 };
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 int usbh_cdc_ncm_get_connect_status(struct usbh_cdc_ncm *cdc_ncm_class);
41 
42 void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class);
43 void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class);
44 
45 uint8_t *usbh_cdc_ncm_get_eth_txbuf(void);
46 int usbh_cdc_ncm_eth_output(uint32_t buflen);
47 void usbh_cdc_ncm_eth_input(uint8_t *buf, uint32_t buflen);
48 void usbh_cdc_ncm_rx_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV);
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 
54 #endif /* USBH_CDC_NCM_H */
55