Modify MessageLength in usbh_rndis_eth_tx
This commit is contained in:
parent
46d67a2115
commit
1d7bcb479d
|
@ -17,6 +17,10 @@ Modification: Modify rndis_host.c according to
|
||||||
2. Date: 2024-07-23
|
2. Date: 2024-07-23
|
||||||
Author: AIIT XUOS Lab
|
Author: AIIT XUOS Lab
|
||||||
Modification: rndis bulk transfer buffer uses physical addresses.
|
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 <usb_osal.h>
|
#include <usb_osal.h>
|
||||||
#include "usbh_core.h"
|
#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. */
|
/* 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 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 Variable Definition*/
|
||||||
static struct usbh_rndis *s_rndis_class_ptr;
|
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]) {
|
if (NDIS_MEDIA_STATE_CONNECTED == data[0]) {
|
||||||
s_rndis_class_ptr->link_status = true;
|
s_rndis_class_ptr->link_status = true;
|
||||||
eth_device_linkchange(RT_TRUE);
|
eth_device_linkchange(true);
|
||||||
printf("linkup, drop pkg\r\n");
|
printf("linkup, drop pkg\r\n");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
s_rndis_class_ptr->link_status = false;
|
s_rndis_class_ptr->link_status = false;
|
||||||
eth_device_linkchange(RT_FALSE);
|
eth_device_linkchange(false);
|
||||||
}
|
}
|
||||||
usb_osal_msleep(100);
|
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]) {
|
if (NDIS_MEDIA_STATE_CONNECTED == data[0]) {
|
||||||
s_rndis_class_ptr->link_status = true;
|
s_rndis_class_ptr->link_status = true;
|
||||||
eth_device_linkchange(RT_TRUE);
|
eth_device_linkchange(true);
|
||||||
printf("linkup, drop pkg\r\n");
|
printf("linkup, drop pkg\r\n");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
s_rndis_class_ptr->link_status = false;
|
s_rndis_class_ptr->link_status = false;
|
||||||
eth_device_linkchange(RT_FALSE);
|
eth_device_linkchange(false);
|
||||||
}
|
}
|
||||||
usb_osal_msleep(100);
|
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));
|
buffer = (uint8_t *)(tx_buffer + sizeof(rndis_data_packet_t));
|
||||||
memcpy(buffer, dataptr, tot_len);
|
memcpy(buffer, dataptr, tot_len);
|
||||||
|
|
||||||
/* send */
|
/* if message length is the multiple of wMaxPacketSize, we should add a short packet to tell device transfer is over. */
|
||||||
if ((hdr->MessageLength & 0x1FF) == 0) {
|
if (!(hdr->MessageLength % s_rndis_class_ptr->ep_mps)) {
|
||||||
/* pad a dummy. */
|
|
||||||
hdr->MessageLength += 1;
|
hdr->MessageLength += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rndis_msg_data_send(s_rndis_class_ptr, (uint8_t *)tx_buffer_phy, hdr->MessageLength);
|
return rndis_msg_data_send(s_rndis_class_ptr, (uint8_t *)tx_buffer_phy, hdr->MessageLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
usbh_hport_activate_epx(&rndis_class->bulkin, hport, ep_desc);
|
||||||
} else {
|
} else {
|
||||||
usbh_hport_activate_epx(&rndis_class->bulkout, hport, ep_desc);
|
usbh_hport_activate_epx(&rndis_class->bulkout, hport, ep_desc);
|
||||||
|
rndis_class->ep_mps = ep_desc->wMaxPacketSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ struct usbh_rndis {
|
||||||
struct usbh_urb bulkout_urb; /* Bulk OUT urb */
|
struct usbh_urb bulkout_urb; /* Bulk OUT urb */
|
||||||
uint32_t request_id;
|
uint32_t request_id;
|
||||||
|
|
||||||
|
uint32_t ep_mps;
|
||||||
uint32_t link_speed;
|
uint32_t link_speed;
|
||||||
bool link_status;
|
bool link_status;
|
||||||
uint8_t mac[6];
|
uint8_t mac[6];
|
||||||
|
|
Loading…
Reference in New Issue