diff --git a/boards/xtensa/intel_s1000_crb/Kconfig.defconfig b/boards/xtensa/intel_s1000_crb/Kconfig.defconfig index e7b420ea801..a7965ca428d 100644 --- a/boards/xtensa/intel_s1000_crb/Kconfig.defconfig +++ b/boards/xtensa/intel_s1000_crb/Kconfig.defconfig @@ -71,18 +71,13 @@ config USB_DW_USB_2_0 default y if USB_DEVICE_HID -config USB_HID_MAX_PAYLOAD_SIZE +config USB_REQUEST_BUFFER_SIZE default 128 endif -config USB_COMPOSITE_BUFFER_SIZE - default 128 - if USB_DFU_CLASS - -config USB_DFU_MAX_XFER_SIZE +config USB_REQUEST_BUFFER_SIZE default 4096 - endif config USB_DEVICE_STACK diff --git a/include/usb/usb_device.h b/include/usb/usb_device.h index f862e19a855..9792e1c1488 100644 --- a/include/usb/usb_device.h +++ b/include/usb/usb_device.h @@ -159,19 +159,6 @@ struct usb_interface_cfg_data { * handler. */ usb_request_handler custom_handler; - /** - * This data area, allocated by the application, is used to store - * Class specific command data and must be large enough to store the - * largest payload associated with the largest supported Class' - * command set. This data area may be used for USB IN or OUT - * communications. - */ - u8_t *payload_data; - /** - * This data area, allocated by the application, is used to store - * Vendor specific payload. - */ - u8_t *vendor_data; }; /** diff --git a/samples/net/wpanusb/prj.conf b/samples/net/wpanusb/prj.conf index dd6696674ba..61ca9cb5b02 100644 --- a/samples/net/wpanusb/prj.conf +++ b/samples/net/wpanusb/prj.conf @@ -3,6 +3,7 @@ CONFIG_USB_DEVICE_PID=0x101 CONFIG_GPIO=y CONFIG_USB=y CONFIG_USB_DEVICE_STACK=y +CONFIG_USB_REQUEST_BUFFER_SIZE=300 CONFIG_UART_INTERRUPT_DRIVEN=y CONFIG_TEST_RANDOM_GENERATOR=y diff --git a/samples/net/wpanusb/src/wpanusb.c b/samples/net/wpanusb/src/wpanusb.c index 58a9afe6442..5a8b1f978a3 100644 --- a/samples/net/wpanusb/src/wpanusb.c +++ b/samples/net/wpanusb/src/wpanusb.c @@ -24,9 +24,6 @@ LOG_MODULE_REGISTER(wpanusb); /* Max packet size for endpoints */ #define WPANUSB_BULK_EP_MPS 64 -/* Max wpanusb command data size */ -#define WPANUSB_CLASS_MAX_DATA_SIZE 100 - #define WPANUSB_ENDP_BULK_IN 0x81 static struct ieee802154_radio_api *radio_api; @@ -37,8 +34,6 @@ static struct k_fifo tx_queue; /* IEEE802.15.4 frame + 1 byte len + 1 byte LQI */ u8_t tx_buf[IEEE802154_MTU + 1 + 1]; -u8_t interface_data[WPANUSB_CLASS_MAX_DATA_SIZE]; - /** * Stack for the tx thread. */ @@ -359,16 +354,11 @@ static void tx_thread(void) } } -/* TODO: FIXME: correct buffer size */ -static u8_t buffer[300]; - static struct usb_cfg_data wpanusb_config = { .usb_device_description = (u8_t *)&wpanusb_desc, .cb_usb_status = wpanusb_status_cb, .interface = { .vendor_handler = wpanusb_vendor_handler, - .vendor_data = buffer, - .payload_data = interface_data, .class_handler = NULL, .custom_handler = NULL, }, diff --git a/samples/subsys/usb/webusb/src/webusb.c b/samples/subsys/usb/webusb/src/webusb.c index 9439ffb7db0..a5d7f60e945 100644 --- a/samples/subsys/usb/webusb/src/webusb.c +++ b/samples/subsys/usb/webusb/src/webusb.c @@ -24,8 +24,6 @@ LOG_MODULE_REGISTER(webusb); /* Max packet size for Bulk endpoints */ #define CDC_BULK_EP_MPS 64 -/* Max CDC ACM class request max data size */ -#define CDC_CLASS_REQ_MAX_DATA_SIZE 8 /* Number of interfaces */ #define WEBUSB_NUM_ITF 0x01 /* Number of Endpoints in the custom interface */ @@ -35,8 +33,6 @@ LOG_MODULE_REGISTER(webusb); static struct webusb_req_handlers *req_handlers; -u8_t interface_data[CDC_CLASS_REQ_MAX_DATA_SIZE]; - u8_t rx_buf[64]; /* Structure representing the global USB description */ @@ -312,8 +308,6 @@ USBD_CFG_DATA_DEFINE(webusb) struct usb_cfg_data webusb_config = { .class_handler = NULL, .custom_handler = webusb_custom_handle_req, .vendor_handler = webusb_vendor_handle_req, - .vendor_data = interface_data, - .payload_data = interface_data, }, .num_endpoints = ARRAY_SIZE(webusb_ep_data), .endpoint = webusb_ep_data diff --git a/subsys/usb/Kconfig b/subsys/usb/Kconfig index a256fb1473d..bbd89cc9a86 100644 --- a/subsys/usb/Kconfig +++ b/subsys/usb/Kconfig @@ -57,9 +57,8 @@ config USB_COMPOSITE_DEVICE help Enable composite USB device driver. -config USB_COMPOSITE_BUFFER_SIZE - int "Set buffer size for Class Handler" - depends on USB_COMPOSITE_DEVICE +config USB_REQUEST_BUFFER_SIZE + int "Set buffer size for Class and Vendor request handlers" default 256 if USB_DEVICE_NETWORK_RNDIS default 64 diff --git a/subsys/usb/class/Kconfig b/subsys/usb/class/Kconfig index 056c47d186b..4fea3a5b0b9 100644 --- a/subsys/usb/class/Kconfig +++ b/subsys/usb/class/Kconfig @@ -141,11 +141,6 @@ config USB_DFU_WAIT_DELAY_MS help A thread can wait for a prescribed time (in ms) for DFU to begin -config USB_DFU_MAX_XFER_SIZE - int - depends on USB_DFU_CLASS - default 64 - config USB_DFU_DETACH_TIMEOUT int depends on USB_DFU_CLASS diff --git a/subsys/usb/class/bluetooth.c b/subsys/usb/class/bluetooth.c index 28408955487..dc899f4011a 100644 --- a/subsys/usb/class/bluetooth.c +++ b/subsys/usb/class/bluetooth.c @@ -23,10 +23,6 @@ #include LOG_MODULE_REGISTER(usb_bluetooth); -#if !defined(CONFIG_USB_COMPOSITE_DEVICE) -static u8_t interface_data[64]; -#endif - static K_FIFO_DEFINE(rx_queue); static K_FIFO_DEFINE(tx_queue); @@ -300,7 +296,6 @@ USBD_CFG_DATA_DEFINE(hci) struct usb_cfg_data bluetooth_config = { .class_handler = bluetooth_class_handler, .custom_handler = NULL, .vendor_handler = NULL, - .payload_data = NULL, }, .num_endpoints = ARRAY_SIZE(bluetooth_ep_data), .endpoint = bluetooth_ep_data, @@ -319,7 +314,6 @@ static int bluetooth_init(struct device *dev) } #ifndef CONFIG_USB_COMPOSITE_DEVICE - bluetooth_config.interface.payload_data = interface_data; bluetooth_config.usb_device_description = usb_get_device_descriptor(); /* Initialize the USB driver with the right configuration */ diff --git a/subsys/usb/class/cdc_acm.c b/subsys/usb/class/cdc_acm.c index ab426691864..2ae0cd6493d 100644 --- a/subsys/usb/class/cdc_acm.c +++ b/subsys/usb/class/cdc_acm.c @@ -67,9 +67,6 @@ LOG_MODULE_REGISTER(usb_cdc_acm); /* Size of the internal buffer used for storing received data */ #define CDC_ACM_BUFFER_SIZE (CONFIG_CDC_ACM_BULK_EP_MPS) -/* Max CDC ACM class request max data size */ -#define CDC_CLASS_REQ_MAX_DATA_SIZE 8 - /* Serial state notification timeout */ #define CDC_CONTROL_SERIAL_STATE_TIMEOUT_US 100000 @@ -189,9 +186,6 @@ struct cdc_acm_dev_data_t { struct ring_buf *rx_ringbuf; struct ring_buf *tx_ringbuf; /* Interface data buffer */ -#ifndef CONFIG_USB_COMPOSITE_DEVICE - u8_t interface_data[CDC_CLASS_REQ_MAX_DATA_SIZE]; -#endif /* CDC ACM line coding properties. LE order */ struct cdc_acm_line_coding line_coding; /* CDC ACM line state bitmap, DTE side */ @@ -531,7 +525,6 @@ static int cdc_acm_init(struct device *dev) #ifndef CONFIG_USB_COMPOSITE_DEVICE struct usb_cfg_data *cfg = (void *)dev->config->config_info; - cfg->interface.payload_data = dev_data->interface_data; cfg->usb_device_description = usb_get_device_descriptor(); /* Initialize the USB driver with the right configuration */ @@ -1001,7 +994,6 @@ static const struct uart_driver_api cdc_acm_driver_api = { .interface = { \ .class_handler = cdc_acm_class_handle_req, \ .custom_handler = NULL, \ - .payload_data = NULL, \ }, \ .num_endpoints = ARRAY_SIZE(cdc_acm_ep_data_##x), \ .endpoint = cdc_acm_ep_data_##x, \ diff --git a/subsys/usb/class/hid/Kconfig b/subsys/usb/class/hid/Kconfig index 944743a6c0e..94cfdcf9d22 100644 --- a/subsys/usb/class/hid/Kconfig +++ b/subsys/usb/class/hid/Kconfig @@ -36,12 +36,6 @@ config HID_INTERRUPT_EP_MPS help USB HID Device interrupt endpoint size -config USB_HID_MAX_PAYLOAD_SIZE - int - default 64 - help - Max allowed payload size over USB HID Class - config USB_HID_POLL_INTERVAL_MS int "Polling interval" default 9 diff --git a/subsys/usb/class/hid/core.c b/subsys/usb/class/hid/core.c index 0dda0222ea0..005c9233846 100644 --- a/subsys/usb/class/hid/core.c +++ b/subsys/usb/class/hid/core.c @@ -640,16 +640,11 @@ static void hid_interface_config(struct usb_desc_header *head, .interface = { \ .class_handler = hid_class_handle_req, \ .custom_handler = hid_custom_handle_req, \ - .payload_data = NULL, \ }, \ .num_endpoints = ARRAY_SIZE(hid_ep_data_##x), \ .endpoint = hid_ep_data_##x, \ }; -#if !defined(CONFIG_USB_COMPOSITE_DEVICE) -static u8_t interface_data[CONFIG_USB_HID_MAX_PAYLOAD_SIZE]; -#endif - int usb_hid_init(const struct device *dev) { struct usb_cfg_data *cfg = (void *)dev->config->config_info; @@ -665,7 +660,6 @@ int usb_hid_init(const struct device *dev) #ifndef CONFIG_USB_COMPOSITE_DEVICE int ret; - cfg->interface.payload_data = interface_data; cfg->usb_device_description = usb_get_device_descriptor(); /* Initialize the USB driver with the right configuration */ diff --git a/subsys/usb/class/loopback.c b/subsys/usb/class/loopback.c index 9b3516cc4a2..3c2c91ed88a 100644 --- a/subsys/usb/class/loopback.c +++ b/subsys/usb/class/loopback.c @@ -23,10 +23,6 @@ LOG_MODULE_REGISTER(usb_loopback); #define LOOPBACK_OUT_EP_IDX 0 #define LOOPBACK_IN_EP_IDX 1 -#if !defined(CONFIG_USB_COMPOSITE_DEVICE) -static u8_t interface_data[64]; -#endif - static u8_t loopback_buf[1024]; /* usb.rst config structure start */ @@ -179,8 +175,6 @@ USBD_CFG_DATA_DEFINE(loopback) struct usb_cfg_data loopback_config = { .class_handler = NULL, .custom_handler = NULL, .vendor_handler = loopback_vendor_handler, - .vendor_data = loopback_buf, - .payload_data = NULL, }, .num_endpoints = ARRAY_SIZE(ep_cfg), .endpoint = ep_cfg, @@ -192,7 +186,6 @@ static int loopback_init(struct device *dev) #ifndef CONFIG_USB_COMPOSITE_DEVICE int ret; - loopback_config.interface.payload_data = interface_data; loopback_config.usb_device_description = usb_get_device_descriptor(); /* usb.rst configure USB controller start */ diff --git a/subsys/usb/class/mass_storage.c b/subsys/usb/class/mass_storage.c index a6103c1c916..d637309f689 100644 --- a/subsys/usb/class/mass_storage.c +++ b/subsys/usb/class/mass_storage.c @@ -862,7 +862,6 @@ USBD_CFG_DATA_DEFINE(msd) struct usb_cfg_data mass_storage_config = { .interface = { .class_handler = mass_storage_class_handle_req, .custom_handler = NULL, - .payload_data = NULL, }, .num_endpoints = ARRAY_SIZE(mass_ep_data), .endpoint = mass_ep_data @@ -901,10 +900,6 @@ static void mass_thread_main(int arg1, int unused) } } -#ifndef CONFIG_USB_COMPOSITE_DEVICE -static u8_t interface_data[64]; -#endif - /** * @brief Initialize USB mass storage setup * @@ -957,7 +952,6 @@ static int mass_storage_init(struct device *dev) #ifndef CONFIG_USB_COMPOSITE_DEVICE int ret; - mass_storage_config.interface.payload_data = interface_data; mass_storage_config.usb_device_description = usb_get_device_descriptor(); /* Initialize the USB driver with the right configuration */ diff --git a/subsys/usb/class/netusb/function_ecm.c b/subsys/usb/class/netusb/function_ecm.c index e73b618a0ef..53f85e18675 100644 --- a/subsys/usb/class/netusb/function_ecm.c +++ b/subsys/usb/class/netusb/function_ecm.c @@ -437,7 +437,6 @@ USBD_CFG_DATA_DEFINE(netusb) struct usb_cfg_data netusb_config = { .class_handler = ecm_class_handler, .custom_handler = NULL, .vendor_handler = NULL, - .payload_data = NULL, }, .num_endpoints = ARRAY_SIZE(ecm_ep_data), .endpoint = ecm_ep_data, diff --git a/subsys/usb/class/netusb/function_eem.c b/subsys/usb/class/netusb/function_eem.c index 71d4db5cf6a..caf390d7bdc 100644 --- a/subsys/usb/class/netusb/function_eem.c +++ b/subsys/usb/class/netusb/function_eem.c @@ -286,7 +286,6 @@ USBD_CFG_DATA_DEFINE(netusb) struct usb_cfg_data netusb_config = { .class_handler = NULL, .custom_handler = NULL, .vendor_handler = NULL, - .payload_data = NULL, }, .num_endpoints = ARRAY_SIZE(eem_ep_data), .endpoint = eem_ep_data, diff --git a/subsys/usb/class/netusb/function_rndis.c b/subsys/usb/class/netusb/function_rndis.c index 702426f8815..02e08ce8c16 100644 --- a/subsys/usb/class/netusb/function_rndis.c +++ b/subsys/usb/class/netusb/function_rndis.c @@ -1173,7 +1173,6 @@ USBD_CFG_DATA_DEFINE(netusb) struct usb_cfg_data netusb_config = { .class_handler = rndis_class_handler, .custom_handler = NULL, .vendor_handler = NULL, - .payload_data = NULL, }, .num_endpoints = ARRAY_SIZE(rndis_ep_data), .endpoint = rndis_ep_data, diff --git a/subsys/usb/class/netusb/netusb.c b/subsys/usb/class/netusb/netusb.c index 833d9d6f135..9cc9aecf117 100644 --- a/subsys/usb/class/netusb/netusb.c +++ b/subsys/usb/class/netusb/netusb.c @@ -26,11 +26,6 @@ static struct __netusb { const struct netusb_function *func; } netusb; -#if !defined(CONFIG_USB_COMPOSITE_DEVICE) -/* TODO: FIXME: correct buffer size */ -static u8_t interface_data[300]; -#endif - static int netusb_send(struct device *dev, struct net_pkt *pkt) { int ret; @@ -154,7 +149,6 @@ static void netusb_init(struct net_if *iface) LOG_DBG("Registering function %u", i); - cfg->interface.payload_data = interface_data; cfg->usb_device_description = usb_get_device_descriptor(); ret = usb_set_config(cfg); diff --git a/subsys/usb/class/usb_dfu.c b/subsys/usb/class/usb_dfu.c index a8a41831b4a..d51bba1010d 100644 --- a/subsys/usb/class/usb_dfu.c +++ b/subsys/usb/class/usb_dfu.c @@ -58,12 +58,7 @@ LOG_MODULE_REGISTER(usb_dfu); #define NUMOF_ALTERNATE_SETTINGS 2 -#ifdef CONFIG_USB_COMPOSITE_DEVICE -#define USB_DFU_MAX_XFER_SIZE (MIN(CONFIG_USB_COMPOSITE_BUFFER_SIZE, \ - CONFIG_USB_DFU_MAX_XFER_SIZE)) -#else -#define USB_DFU_MAX_XFER_SIZE CONFIG_USB_DFU_MAX_XFER_SIZE -#endif +#define USB_DFU_MAX_XFER_SIZE CONFIG_USB_REQUEST_BUFFER_SIZE #define FIRMWARE_IMAGE_0_LABEL "image-1" #define FIRMWARE_IMAGE_1_LABEL "image-0" @@ -711,7 +706,6 @@ USBD_CFG_DATA_DEFINE(dfu) struct usb_cfg_data dfu_config = { .interface = { .class_handler = dfu_class_handle_req, .custom_handler = dfu_custom_handle_req, - .payload_data = dfu_data.buffer, }, .num_endpoints = 0, }; @@ -728,7 +722,6 @@ USBD_CFG_DATA_DEFINE(dfu_mode) struct usb_cfg_data dfu_mode_config = { .interface = { .class_handler = dfu_class_handle_req, .custom_handler = dfu_custom_handle_req, - .payload_data = dfu_data.buffer, }, .num_endpoints = 0, }; diff --git a/subsys/usb/usb_device.c b/subsys/usb/usb_device.c index 6e9856ce3be..ac176327659 100644 --- a/subsys/usb/usb_device.c +++ b/subsys/usb/usb_device.c @@ -158,6 +158,9 @@ static struct usb_dev_priv { u8_t *data_store[MAX_NUM_REQ_HANDLERS]; /* Buffer used for storing standard usb request data */ u8_t std_req_data[MAX_STD_REQ_MSG_SIZE]; + /* Buffer used for storing class and vendor request data */ + u8_t class_vendor_req_data[CONFIG_USB_REQUEST_BUFFER_SIZE]; + /** Variable to check whether the usb has been enabled */ bool enabled; /** Variable to check whether the usb has been configured */ @@ -1043,14 +1046,14 @@ int usb_set_config(struct usb_cfg_data *config) if (config->interface.class_handler != NULL) { usb_register_request_handler(REQTYPE_TYPE_CLASS, config->interface.class_handler, - config->interface.payload_data); + usb_dev.class_vendor_req_data); } /* register vendor request handler */ if (config->interface.vendor_handler || usb_os_desc_enabled()) { usb_register_request_handler(REQTYPE_TYPE_VENDOR, usb_handle_vendor_request, - config->interface.vendor_data); + usb_dev.class_vendor_req_data); if (config->interface.vendor_handler) { usb_dev.vendor_req_handler = @@ -1522,8 +1525,6 @@ int usb_wakeup_request(void) #ifdef CONFIG_USB_COMPOSITE_DEVICE -static u8_t iface_data_buf[CONFIG_USB_COMPOSITE_BUFFER_SIZE]; - /* * The functions class_handler(), custom_handler() and vendor_handler() * go through the interfaces one after the other and compare the @@ -1659,12 +1660,12 @@ static int usb_composite_init(struct device *dev) /* register class request handlers for each interface*/ usb_register_request_handler(REQTYPE_TYPE_CLASS, class_handler, - iface_data_buf); + usb_dev.class_vendor_req_data); /* register vendor request handlers */ usb_register_request_handler(REQTYPE_TYPE_VENDOR, vendor_handler, - iface_data_buf); + usb_dev.class_vendor_req_data); /* register class request handlers for each interface*/ usb_register_custom_req_handler(custom_handler); diff --git a/tests/subsys/usb/desc_sections/src/desc_sections.c b/tests/subsys/usb/desc_sections/src/desc_sections.c index 06e3db61007..5b46b4b64ce 100644 --- a/tests/subsys/usb/desc_sections/src/desc_sections.c +++ b/tests/subsys/usb/desc_sections/src/desc_sections.c @@ -101,8 +101,6 @@ struct usb_test_config { .class_handler = NULL, \ .custom_handler = NULL, \ .vendor_handler = NULL, \ - .vendor_data = NULL, \ - .payload_data = NULL, \ }, \ .num_endpoints = ARRAY_SIZE(ep_cfg_##x), \ .endpoint = ep_cfg_##x, \