zero copy when enables LWIP_TCPIP_CORE_LOCKING_INPUT

This commit is contained in:
sakumisu
2024-05-03 19:53:22 +08:00
parent ae5a9d1e57
commit 0ceb7ef885
5 changed files with 53 additions and 16 deletions

View File

@@ -232,6 +232,11 @@ void usbh_cdc_ecm_rx_thread(void *argument)
int ret;
err_t err;
struct pbuf *p;
#ifdef LWIP_TCPIP_CORE_LOCKING_INPUT
pbuf_type type = PBUF_ROM;
#else
pbuf_type type = PBUF_POOL;
#endif
struct netif *netif = (struct netif *)argument;
USB_LOG_INFO("Create cdc ecm rx thread\r\n");
@@ -264,9 +269,13 @@ find_class:
if (g_cdc_ecm_class.bulkin_urb.actual_length != USB_GET_MAXPACKETSIZE(g_cdc_ecm_class.bulkin->wMaxPacketSize)) {
USB_LOG_DBG("rxlen:%d\r\n", g_cdc_ecm_rx_length);
p = pbuf_alloc(PBUF_RAW, g_cdc_ecm_rx_length, PBUF_POOL);
p = pbuf_alloc(PBUF_RAW, g_cdc_ecm_rx_length, type);
if (p != NULL) {
#ifdef LWIP_TCPIP_CORE_LOCKING_INPUT
p->payload = g_cdc_ecm_rx_buffer;
#else
memcpy(p->payload, (uint8_t *)g_cdc_ecm_rx_buffer, g_cdc_ecm_rx_length);
#endif
g_cdc_ecm_rx_length = 0;
err = netif->input(p, netif);

View File

@@ -258,6 +258,11 @@ void usbh_cdc_ncm_rx_thread(void *argument)
int ret;
err_t err;
struct pbuf *p;
#ifdef LWIP_TCPIP_CORE_LOCKING_INPUT
pbuf_type type = PBUF_ROM;
#else
pbuf_type type = PBUF_POOL;
#endif
struct netif *netif = (struct netif *)argument;
USB_LOG_INFO("Create cdc ncm rx thread\r\n");
@@ -314,10 +319,13 @@ find_class:
if (ndp16_datagram->wDatagramIndex && ndp16_datagram->wDatagramLength) {
USB_LOG_DBG("ndp16_datagram index:%02x, length:%02x\r\n", ndp16_datagram->wDatagramIndex, ndp16_datagram->wDatagramLength);
p = pbuf_alloc(PBUF_RAW, ndp16_datagram->wDatagramLength, PBUF_POOL);
p = pbuf_alloc(PBUF_RAW, ndp16_datagram->wDatagramLength, type);
if (p != NULL) {
#ifdef LWIP_TCPIP_CORE_LOCKING_INPUT
p->payload = (uint8_t *)&g_cdc_ncm_rx_buffer[ndp16_datagram->wDatagramIndex];
#else
memcpy(p->payload, (uint8_t *)&g_cdc_ncm_rx_buffer[ndp16_datagram->wDatagramIndex], ndp16_datagram->wDatagramLength);
#endif
err = netif->input(p, netif);
if (err != ERR_OK) {
pbuf_free(p);

View File

@@ -657,6 +657,11 @@ void usbh_asix_rx_thread(void *argument)
uint16_t len;
uint16_t len_crc;
struct pbuf *p;
#ifdef LWIP_TCPIP_CORE_LOCKING_INPUT
pbuf_type type = PBUF_ROM;
#else
pbuf_type type = PBUF_POOL;
#endif
struct netif *netif = (struct netif *)argument;
USB_LOG_INFO("Create asix rx thread\r\n");
@@ -697,9 +702,13 @@ find_class:
USB_LOG_DBG("rxlen:%d\r\n", g_asix_rx_length);
p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
p = pbuf_alloc(PBUF_RAW, len, type);
if (p != NULL) {
#ifdef LWIP_TCPIP_CORE_LOCKING_INPUT
p->payload = (uint8_t *)&g_asix_rx_buffer[4];
#else
memcpy(p->payload, (uint8_t *)&g_asix_rx_buffer[4], len);
#endif
g_asix_rx_length = 0;
err = netif->input(p, netif);

View File

@@ -2129,6 +2129,11 @@ void usbh_rtl8152_rx_thread(void *argument)
uint16_t len;
uint16_t data_offset;
struct pbuf *p;
#ifdef LWIP_TCPIP_CORE_LOCKING_INPUT
pbuf_type type = PBUF_ROM;
#else
pbuf_type type = PBUF_POOL;
#endif
struct netif *netif = (struct netif *)argument;
USB_LOG_INFO("Create rtl8152 rx thread\r\n");
@@ -2179,10 +2184,13 @@ find_class:
USB_LOG_DBG("data_offset:%d, eth len:%d\r\n", data_offset, len);
p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
p = pbuf_alloc(PBUF_RAW, len, type);
if (p != NULL) {
#ifdef LWIP_TCPIP_CORE_LOCKING_INPUT
p->payload = (uint8_t *)&g_rtl8152_rx_buffer[data_offset + sizeof(struct rx_desc)];
#else
memcpy(p->payload, (uint8_t *)&g_rtl8152_rx_buffer[data_offset + sizeof(struct rx_desc)], len);
#endif
err = netif->input(p, netif);
if (err != ERR_OK) {
pbuf_free(p);

View File

@@ -434,12 +434,16 @@ void usbh_rndis_rx_thread(void *argument)
{
uint32_t g_rndis_rx_length;
uint32_t pmg_offset;
uint32_t payload_offset;
int ret;
err_t err;
struct pbuf *p, *q;
struct pbuf *p;
rndis_data_packet_t *pmsg;
rndis_data_packet_t temp;
#ifdef LWIP_TCPIP_CORE_LOCKING_INPUT
pbuf_type type = PBUF_ROM;
#else
pbuf_type type = PBUF_POOL;
#endif
struct netif *netif = (struct netif *)argument;
USB_LOG_INFO("Create rndis rx thread\r\n");
@@ -482,15 +486,14 @@ find_class:
}
if (pmsg->MessageType == REMOTE_NDIS_PACKET_MSG) {
p = pbuf_alloc(PBUF_RAW, pmsg->DataLength, PBUF_POOL);
p = pbuf_alloc(PBUF_RAW, pmsg->DataLength, type);
if (p != NULL) {
payload_offset = 0;
for (q = p; q != NULL; q = q->next) {
void *src = (void *)(g_rndis_rx_buffer + pmg_offset + sizeof(rndis_generic_msg_t) + pmsg->DataOffset + payload_offset);
memcpy(q->payload, src, q->len);
payload_offset += q->len;
}
void *src = (void *)(g_rndis_rx_buffer + pmg_offset + sizeof(rndis_generic_msg_t) + pmsg->DataOffset);
#ifdef LWIP_TCPIP_CORE_LOCKING_INPUT
p->payload = src;
#else
memcpy(q->payload, src, pmsg->DataLength);
#endif
err = netif->input(p, netif);
if (err != ERR_OK) {
pbuf_free(p);