From 58e26246f6002665dada24c4b4363e8789a9060f Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Fri, 31 Mar 2023 14:28:39 +0200 Subject: [PATCH] cdc_ecm: Update max supported transfer size after reset --- sys/usb/usbus/cdc/ecm/cdc_ecm.c | 6 ++++++ sys/usb/usbus/cdc/ecm/cdc_ecm_netdev.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/usb/usbus/cdc/ecm/cdc_ecm.c b/sys/usb/usbus/cdc/ecm/cdc_ecm.c index 7fa4f8cd8fd00..9d0ff886ded71 100644 --- a/sys/usb/usbus/cdc/ecm/cdc_ecm.c +++ b/sys/usb/usbus/cdc/ecm/cdc_ecm.c @@ -336,6 +336,12 @@ static void _handle_reset(usbus_t *usbus, usbus_handler_t *handler) { usbus_cdcecm_device_t *cdcecm = (usbus_cdcecm_device_t *)handler; + /* Set the max packet size advertised to the host to something compatible with the enumerated + * size */ + size_t maxpacketsize = usbus_max_bulk_endpoint_size(usbus); + cdcecm->ep_in->maxpacketsize = maxpacketsize; + cdcecm->ep_out->maxpacketsize = maxpacketsize; + DEBUG("CDC ECM: Reset\n"); _handle_in_complete(usbus, handler); cdcecm->notif = USBUS_CDCECM_NOTIF_NONE; diff --git a/sys/usb/usbus/cdc/ecm/cdc_ecm_netdev.c b/sys/usb/usbus/cdc/ecm/cdc_ecm_netdev.c index 5cdfdc2c40c22..070352d017163 100644 --- a/sys/usb/usbus/cdc/ecm/cdc_ecm_netdev.c +++ b/sys/usb/usbus/cdc/ecm/cdc_ecm_netdev.c @@ -71,7 +71,7 @@ static int _send(netdev_t *netdev, const iolist_t *iolist) /* load packet data into FIFO */ size_t iol_offset = 0; size_t usb_offset = 0; - size_t usb_remain = cdcecm->ep_in->ep->len; + size_t usb_remain = cdcecm->ep_in->maxpacketsize; DEBUG("CDC_ECM_netdev: cur iol: %d\n", iolist->iol_len); while (len) { mutex_lock(&cdcecm->out_lock);