diff --git a/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/rndis_host.c b/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/rndis_host.c index 7b9889d66..a09cd73c2 100644 --- a/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/rndis_host.c +++ b/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/rndis_host.c @@ -17,6 +17,10 @@ Modification: Modify rndis_host.c according to 2. Date: 2024-07-23 Author: AIIT XUOS Lab Modification: rndis bulk transfer buffer uses physical addresses. + +3. Date: 2024-07-23 +Author: AIIT XUOS Lab +Modification: Modify MessageLength in usbh_rndis_eth_tx, see https://github.com/cherry-embedded/CherryUSB. *************************************************/ #include #include "usbh_core.h" @@ -42,9 +46,6 @@ Modification: rndis bulk transfer buffer uses physical addresses. /* The maximum number of concatenated REMOTE_NDIS_PACKET_MSG messages in a single bus transfer to it, see MaxPacketsPerTransfer in REMOTE_NDIS_INITIALIZE_CMPLT. */ #define RNDIS_RXETH_BUFFER_LEN (RNDIS_ETH_BUFFER_LEN * 1) -#define RT_TRUE 1 /**< boolean true */ -#define RT_FALSE 0 /**< boolean fails */ - /* Static Variable Definition*/ static struct usbh_rndis *s_rndis_class_ptr; @@ -99,12 +100,12 @@ static void usbh_rndis_data_recv_entry(void *pdata) } if (NDIS_MEDIA_STATE_CONNECTED == data[0]) { s_rndis_class_ptr->link_status = true; - eth_device_linkchange(RT_TRUE); + eth_device_linkchange(true); printf("linkup, drop pkg\r\n"); break; } else { s_rndis_class_ptr->link_status = false; - eth_device_linkchange(RT_FALSE); + eth_device_linkchange(false); } usb_osal_msleep(100); } @@ -211,12 +212,12 @@ int usbh_rndis_eth_tx(void *dataptr, size_t tot_len) } if (NDIS_MEDIA_STATE_CONNECTED == data[0]) { s_rndis_class_ptr->link_status = true; - eth_device_linkchange(RT_TRUE); + eth_device_linkchange(true); printf("linkup, drop pkg\r\n"); break; } else { s_rndis_class_ptr->link_status = false; - eth_device_linkchange(RT_FALSE); + eth_device_linkchange(false); } usb_osal_msleep(100); } @@ -239,11 +240,11 @@ int usbh_rndis_eth_tx(void *dataptr, size_t tot_len) buffer = (uint8_t *)(tx_buffer + sizeof(rndis_data_packet_t)); memcpy(buffer, dataptr, tot_len); - /* send */ - if ((hdr->MessageLength & 0x1FF) == 0) { - /* pad a dummy. */ + /* if message length is the multiple of wMaxPacketSize, we should add a short packet to tell device transfer is over. */ + if (!(hdr->MessageLength % s_rndis_class_ptr->ep_mps)) { hdr->MessageLength += 1; } + return rndis_msg_data_send(s_rndis_class_ptr, (uint8_t *)tx_buffer_phy, hdr->MessageLength); } diff --git a/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/usbh_rndis.c b/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/usbh_rndis.c index 61259a7be..96bcb47f5 100644 --- a/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/usbh_rndis.c +++ b/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/usbh_rndis.c @@ -321,6 +321,7 @@ static int usbh_rndis_connect(struct usbh_hubport *hport, uint8_t intf) usbh_hport_activate_epx(&rndis_class->bulkin, hport, ep_desc); } else { usbh_hport_activate_epx(&rndis_class->bulkout, hport, ep_desc); + rndis_class->ep_mps = ep_desc->wMaxPacketSize; } } diff --git a/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/usbh_rndis.h b/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/usbh_rndis.h index 4d0dfaf28..2f7e293c9 100644 --- a/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/usbh_rndis.h +++ b/Ubiquitous/XiZi_AIoT/services/drivers/usb/components/class/wireless/usbh_rndis.h @@ -37,6 +37,7 @@ struct usbh_rndis { struct usbh_urb bulkout_urb; /* Bulk OUT urb */ uint32_t request_id; + uint32_t ep_mps; uint32_t link_speed; bool link_status; uint8_t mac[6];