summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2024-06-25 17:18:09 +0800
committersakumisu <[email protected]>2024-06-25 17:18:19 +0800
commit6c92681e4869212c8fd7f3b03cbf56de9a25191b (patch)
treebab3378b4e24e929269bbe2179a12113fd2fabe0
parent31cd834dedb617128e361c3024a03a0831aa9dd5 (diff)
refactor(platform): add usbh_xxx_get_eth_txbuf api, especially for lwip pbuf list
-rw-r--r--class/cdc/usbh_cdc_ecm.c9
-rw-r--r--class/cdc/usbh_cdc_ecm.h3
-rw-r--r--class/cdc/usbh_cdc_ncm.c11
-rw-r--r--class/cdc/usbh_cdc_ncm.h3
-rw-r--r--class/vendor/net/usbh_asix.c11
-rw-r--r--class/vendor/net/usbh_asix.h3
-rw-r--r--class/vendor/net/usbh_rtl8152.c11
-rw-r--r--class/vendor/net/usbh_rtl8152.h3
-rw-r--r--class/wireless/usbh_rndis.c11
-rw-r--r--class/wireless/usbh_rndis.h3
-rw-r--r--platform/none/usbh_lwip.c43
-rw-r--r--platform/nuttx/usbh_net.c27
-rw-r--r--platform/rtthread/usbh_lwip.c43
13 files changed, 127 insertions, 54 deletions
diff --git a/class/cdc/usbh_cdc_ecm.c b/class/cdc/usbh_cdc_ecm.c
index 3997782f..ad05d516 100644
--- a/class/cdc/usbh_cdc_ecm.c
+++ b/class/cdc/usbh_cdc_ecm.c
@@ -287,16 +287,17 @@ delete:
// clang-format on
}
-int usbh_cdc_ecm_eth_output(uint8_t *buf, uint32_t buflen)
+uint8_t *usbh_cdc_ecm_get_eth_txbuf(void)
{
- uint8_t *buffer = g_cdc_ecm_tx_buffer;
+ return g_cdc_ecm_tx_buffer;
+}
+int usbh_cdc_ecm_eth_output(uint32_t buflen)
+{
if (g_cdc_ecm_class.connect_status == false) {
return -USB_ERR_NOTCONN;
}
- usb_memcpy(buffer, buf, buflen);
-
USB_LOG_DBG("txlen:%d\r\n", buflen);
usbh_bulk_urb_fill(&g_cdc_ecm_class.bulkout_urb, g_cdc_ecm_class.hport, g_cdc_ecm_class.bulkout, g_cdc_ecm_tx_buffer, buflen, USB_OSAL_WAITING_FOREVER, NULL, NULL);
diff --git a/class/cdc/usbh_cdc_ecm.h b/class/cdc/usbh_cdc_ecm.h
index d965ac88..6e8dbc7f 100644
--- a/class/cdc/usbh_cdc_ecm.h
+++ b/class/cdc/usbh_cdc_ecm.h
@@ -38,7 +38,8 @@ int usbh_cdc_ecm_get_connect_status(struct usbh_cdc_ecm *cdc_ecm_class);
void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class);
void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class);
-int usbh_cdc_ecm_eth_output(uint8_t *buf, uint32_t buflen);
+uint8_t *usbh_cdc_ecm_get_eth_txbuf(void);
+int usbh_cdc_ecm_eth_output(uint32_t buflen);
void usbh_cdc_ecm_eth_input(uint8_t *buf, uint32_t buflen);
void usbh_cdc_ecm_rx_thread(void *argument);
diff --git a/class/cdc/usbh_cdc_ncm.c b/class/cdc/usbh_cdc_ncm.c
index c659664a..99e8871e 100644
--- a/class/cdc/usbh_cdc_ncm.c
+++ b/class/cdc/usbh_cdc_ncm.c
@@ -343,9 +343,13 @@ delete:
// clang-format on
}
-int usbh_cdc_ncm_eth_output(uint8_t *buf, uint32_t buflen)
+uint8_t *usbh_cdc_ncm_get_eth_txbuf(void)
+{
+ return &g_cdc_ncm_tx_buffer[16];
+}
+
+int usbh_cdc_ncm_eth_output(uint32_t buflen)
{
- uint8_t *buffer;
struct cdc_ncm_ndp16_datagram *ndp16_datagram;
if (g_cdc_ncm_class.connect_status == false) {
@@ -374,9 +378,6 @@ int usbh_cdc_ncm_eth_output(uint8_t *buf, uint32_t buflen)
ndp16_datagram->wDatagramIndex = 0;
ndp16_datagram->wDatagramLength = 0;
- buffer = &g_cdc_ncm_tx_buffer[16];
- usb_memcpy(buffer, buf, buflen);
-
USB_LOG_DBG("txlen:%d\r\n", nth16->wBlockLength);
usbh_bulk_urb_fill(&g_cdc_ncm_class.bulkout_urb, g_cdc_ncm_class.hport, g_cdc_ncm_class.bulkout, g_cdc_ncm_tx_buffer, nth16->wBlockLength, USB_OSAL_WAITING_FOREVER, NULL, NULL);
diff --git a/class/cdc/usbh_cdc_ncm.h b/class/cdc/usbh_cdc_ncm.h
index 5f069401..e9b3e8e0 100644
--- a/class/cdc/usbh_cdc_ncm.h
+++ b/class/cdc/usbh_cdc_ncm.h
@@ -42,7 +42,8 @@ int usbh_cdc_ncm_get_connect_status(struct usbh_cdc_ncm *cdc_ncm_class);
void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class);
void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class);
-int usbh_cdc_ncm_eth_output(uint8_t *buf, uint32_t buflen);
+uint8_t *usbh_cdc_ncm_get_eth_txbuf(void);
+int usbh_cdc_ncm_eth_output(uint32_t buflen);
void usbh_cdc_ncm_eth_input(uint8_t *buf, uint32_t buflen);
void usbh_cdc_ncm_rx_thread(void *argument);
diff --git a/class/vendor/net/usbh_asix.c b/class/vendor/net/usbh_asix.c
index cf761778..a96fa26b 100644
--- a/class/vendor/net/usbh_asix.c
+++ b/class/vendor/net/usbh_asix.c
@@ -751,18 +751,19 @@ delete:
// clang-format on
}
-int usbh_asix_eth_output(uint8_t *buf, uint32_t buflen)
+uint8_t *usbh_asix_get_eth_txbuf(void)
+{
+ return &g_asix_tx_buffer[4];
+}
+
+int usbh_asix_eth_output(uint32_t buflen)
{
uint16_t actual_len;
- uint8_t *buffer;
if (g_asix_class.connect_status == false) {
return -USB_ERR_NOTCONN;
}
- buffer = &g_asix_tx_buffer[4];
- usb_memcpy(buffer, buf, buflen);
-
g_asix_tx_buffer[0] = buflen & 0xff;
g_asix_tx_buffer[1] = (buflen >> 8) & 0xff;
g_asix_tx_buffer[2] = ~g_asix_tx_buffer[0];
diff --git a/class/vendor/net/usbh_asix.h b/class/vendor/net/usbh_asix.h
index 9f34e570..8b0b5d98 100644
--- a/class/vendor/net/usbh_asix.h
+++ b/class/vendor/net/usbh_asix.h
@@ -165,7 +165,8 @@ int usbh_asix_get_connect_status(struct usbh_asix *asix_class);
void usbh_asix_run(struct usbh_asix *asix_class);
void usbh_asix_stop(struct usbh_asix *asix_class);
-int usbh_asix_eth_output(uint8_t *buf, uint32_t buflen);
+uint8_t *usbh_asix_get_eth_txbuf(void);
+int usbh_asix_eth_output(uint32_t buflen);
void usbh_asix_eth_input(uint8_t *buf, uint32_t buflen);
void usbh_asix_rx_thread(void *argument);
diff --git a/class/vendor/net/usbh_rtl8152.c b/class/vendor/net/usbh_rtl8152.c
index a9f794e2..dde665db 100644
--- a/class/vendor/net/usbh_rtl8152.c
+++ b/class/vendor/net/usbh_rtl8152.c
@@ -2223,9 +2223,13 @@ delete:
// clang-format on
}
-int usbh_rtl8152_eth_output(uint8_t *buf, uint32_t buflen)
+uint8_t *usbh_rtl8152_get_eth_txbuf(void)
+{
+ return (g_rtl8152_tx_buffer + sizeof(struct tx_desc));
+}
+
+int usbh_rtl8152_eth_output(uint32_t buflen)
{
- uint8_t *buffer;
struct tx_desc *tx_desc;
if (g_rtl8152_class.connect_status == false) {
@@ -2236,9 +2240,6 @@ int usbh_rtl8152_eth_output(uint8_t *buf, uint32_t buflen)
tx_desc->opts1 = buflen | TX_FS | TX_LS;
tx_desc->opts2 = 0;
- buffer = g_rtl8152_tx_buffer + sizeof(struct tx_desc);
- usb_memcpy(buffer, buf, buflen);
-
USB_LOG_DBG("txlen:%d\r\n", buflen + sizeof(struct tx_desc));
usbh_bulk_urb_fill(&g_rtl8152_class.bulkout_urb, g_rtl8152_class.hport, g_rtl8152_class.bulkout, g_rtl8152_tx_buffer, buflen + sizeof(struct tx_desc), USB_OSAL_WAITING_FOREVER, NULL, NULL);
diff --git a/class/vendor/net/usbh_rtl8152.h b/class/vendor/net/usbh_rtl8152.h
index a9aa7943..9d593b91 100644
--- a/class/vendor/net/usbh_rtl8152.h
+++ b/class/vendor/net/usbh_rtl8152.h
@@ -56,7 +56,8 @@ int usbh_rtl8152_get_connect_status(struct usbh_rtl8152 *rtl8152_class);
void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class);
void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class);
-int usbh_rtl8152_eth_output(uint8_t *buf, uint32_t buflen);
+uint8_t *usbh_rtl8152_get_eth_txbuf(void);
+int usbh_rtl8152_eth_output(uint32_t buflen);
void usbh_rtl8152_eth_input(uint8_t *buf, uint32_t buflen);
void usbh_rtl8152_rx_thread(void *argument);
diff --git a/class/wireless/usbh_rndis.c b/class/wireless/usbh_rndis.c
index 4495ea58..e722e50c 100644
--- a/class/wireless/usbh_rndis.c
+++ b/class/wireless/usbh_rndis.c
@@ -545,9 +545,13 @@ delete:
// clang-format on
}
-int usbh_rndis_eth_output(uint8_t *buf, uint32_t buflen)
+uint8_t *usbh_rndis_get_eth_txbuf(void)
+{
+ return (g_rndis_tx_buffer + sizeof(rndis_data_packet_t));
+}
+
+int usbh_rndis_eth_output(uint32_t buflen)
{
- uint8_t *buffer;
rndis_data_packet_t *hdr;
uint32_t len;
@@ -563,9 +567,6 @@ int usbh_rndis_eth_output(uint8_t *buf, uint32_t buflen)
hdr->DataOffset = sizeof(rndis_data_packet_t) - sizeof(rndis_generic_msg_t);
hdr->DataLength = buflen;
- buffer = (uint8_t *)(g_rndis_tx_buffer + sizeof(rndis_data_packet_t));
- usb_memcpy(buffer, buf, buflen);
-
len = hdr->MessageLength;
/* if message length is the multiple of wMaxPacketSize, we should add a short packet to tell device transfer is over. */
if (!(len % g_rndis_class.bulkout->wMaxPacketSize)) {
diff --git a/class/wireless/usbh_rndis.h b/class/wireless/usbh_rndis.h
index 8bdd072a..17a40006 100644
--- a/class/wireless/usbh_rndis.h
+++ b/class/wireless/usbh_rndis.h
@@ -43,7 +43,8 @@ int usbh_rndis_keepalive(struct usbh_rndis *rndis_class);
void usbh_rndis_run(struct usbh_rndis *rndis_class);
void usbh_rndis_stop(struct usbh_rndis *rndis_class);
-int usbh_rndis_eth_output(uint8_t *buf, uint32_t buflen);
+uint8_t *usbh_rndis_get_eth_txbuf(void);
+int usbh_rndis_eth_output(uint32_t buflen);
void usbh_rndis_eth_input(uint8_t *buf, uint32_t buflen);
void usbh_rndis_rx_thread(void *argument);
diff --git a/platform/none/usbh_lwip.c b/platform/none/usbh_lwip.c
index f6091378..aaf67b0e 100644
--- a/platform/none/usbh_lwip.c
+++ b/platform/none/usbh_lwip.c
@@ -19,11 +19,11 @@
#include "usbh_core.h"
-#if LWIP_TCPIP_CORE_LOCKING_INPUT !=1
+#if LWIP_TCPIP_CORE_LOCKING_INPUT != 1
#warning suggest you to set LWIP_TCPIP_CORE_LOCKING_INPUT to 1, usb handles eth input with own thread
#endif
-#if LWIP_TCPIP_CORE_LOCKING !=1
+#if LWIP_TCPIP_CORE_LOCKING != 1
#error must set LWIP_TCPIP_CORE_LOCKING to 1
#endif
@@ -41,6 +41,18 @@ ip_addr_t g_ipaddr;
ip_addr_t g_netmask;
ip_addr_t g_gateway;
+void usbh_lwip_eth_output_common(struct pbuf *p, uint8_t *buf)
+{
+ struct pbuf *q;
+ uint8_t *buffer;
+
+ buffer = buf;
+ for (q = p; q != NULL; q = q->next) {
+ usb_memcpy(buffer, q->payload, q->len);
+ buffer += q->len;
+ }
+}
+
void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len)
{
#if LWIP_TCPIP_CORE_LOCKING_INPUT
@@ -56,7 +68,7 @@ void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len)
#if LWIP_TCPIP_CORE_LOCKING_INPUT
p->payload = buf;
#else
- memcpy(p->payload, buf, len);
+ usb_memcpy(p->payload, buf, len);
#endif
err = netif->input(p, netif);
if (err != ERR_OK) {
@@ -94,7 +106,10 @@ struct netif g_cdc_ecm_netif;
static err_t usbh_cdc_ecm_linkoutput(struct netif *netif, struct pbuf *p)
{
- int ret = usbh_cdc_ecm_eth_output(p->payload, p->tot_len);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_cdc_ecm_get_eth_txbuf());
+ ret = usbh_cdc_ecm_eth_output(p->tot_len);
if (ret < 0) {
return ERR_BUF;
} else {
@@ -193,7 +208,10 @@ struct netif g_rndis_netif;
static err_t usbh_rndis_linkoutput(struct netif *netif, struct pbuf *p)
{
- int ret = usbh_rndis_eth_output(p->payload, p->tot_len);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_rndis_get_eth_txbuf());
+ ret = usbh_rndis_eth_output(p->tot_len);
if (ret < 0) {
return ERR_BUF;
} else {
@@ -276,7 +294,10 @@ struct netif g_cdc_ncm_netif;
static err_t usbh_cdc_ncm_linkoutput(struct netif *netif, struct pbuf *p)
{
- int ret = usbh_cdc_ncm_eth_output(p->payload, p->tot_len);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_cdc_ncm_get_eth_txbuf());
+ ret = usbh_cdc_ncm_eth_output(p->tot_len);
if (ret < 0) {
return ERR_BUF;
} else {
@@ -354,7 +375,10 @@ struct netif g_asix_netif;
static err_t usbh_asix_linkoutput(struct netif *netif, struct pbuf *p)
{
- int ret = usbh_asix_eth_output(p->payload, p->tot_len);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_asix_get_eth_txbuf());
+ ret = usbh_asix_eth_output(p->tot_len);
if (ret < 0) {
return ERR_BUF;
} else {
@@ -432,7 +456,10 @@ struct netif g_rtl8152_netif;
static err_t usbh_rtl8152_linkoutput(struct netif *netif, struct pbuf *p)
{
- int ret = usbh_rtl8152_eth_output(p->payload, p->tot_len);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_rtl8152_get_eth_txbuf());
+ ret = usbh_rtl8152_eth_output(p->tot_len);
if (ret < 0) {
return ERR_BUF;
} else {
diff --git a/platform/nuttx/usbh_net.c b/platform/nuttx/usbh_net.c
index b034ecc8..d82311df 100644
--- a/platform/nuttx/usbh_net.c
+++ b/platform/nuttx/usbh_net.c
@@ -18,11 +18,11 @@
#include "usbh_core.h"
-#define CONFIG_USBHOST_PLATFORM_CDC_ECM
+// #define CONFIG_USBHOST_PLATFORM_CDC_ECM
#define CONFIG_USBHOST_PLATFORM_CDC_RNDIS
-#define CONFIG_USBHOST_PLATFORM_CDC_NCM
-#define CONFIG_USBHOST_PLATFORM_ASIX
-#define CONFIG_USBHOST_PLATFORM_RTL8152
+// #define CONFIG_USBHOST_PLATFORM_CDC_NCM
+// #define CONFIG_USBHOST_PLATFORM_ASIX
+// #define CONFIG_USBHOST_PLATFORM_RTL8152
struct usbh_net {
struct net_driver_s netdev;
@@ -30,7 +30,12 @@ struct usbh_net {
bool linkup;
};
-void usbh_net_eth_input_common(struct net_driver_s *dev, uint8_t *buf, size_t len, int (*eth_output)(uint8_t *buf, uint32_t buflen))
+void usbh_net_eth_output_common(struct net_driver_s *dev, uint8_t *buf)
+{
+ usb_memcpy(buf, dev->d_buf, dev->d_len);
+}
+
+void usbh_net_eth_input_common(struct net_driver_s *dev, uint8_t *buf, size_t len, int (*eth_output)(uint32_t buflen))
{
FAR struct eth_hdr_s *hdr;
@@ -56,7 +61,8 @@ void usbh_net_eth_input_common(struct net_driver_s *dev, uint8_t *buf, size_t le
ipv4_input(dev);
if (dev->d_len > 0) {
/* And send the packet */
- eth_output(dev->d_buf, dev->d_len);
+ usbh_net_eth_output_common(dev, usbh_rndis_get_eth_txbuf());
+ eth_output(dev->d_len);
}
} else
#endif
@@ -70,7 +76,8 @@ void usbh_net_eth_input_common(struct net_driver_s *dev, uint8_t *buf, size_t le
if (dev->d_len > 0) {
/* And send the packet */
- eth_output(dev->d_buf, dev->d_len);
+ usbh_net_eth_output_common(dev, usbh_rndis_get_eth_txbuf());
+ eth_output(dev->d_len);
}
} else
#endif
@@ -80,7 +87,8 @@ void usbh_net_eth_input_common(struct net_driver_s *dev, uint8_t *buf, size_t le
arp_input(dev);
if (dev->d_len > 0) {
- eth_output(dev->d_buf, dev->d_len);
+ usbh_net_eth_output_common(dev, usbh_rndis_get_eth_txbuf());
+ eth_output(dev->d_len);
}
} else
#endif
@@ -113,7 +121,8 @@ static int rndis_ifdown(struct net_driver_s *dev)
static int rndis_txpoll(struct net_driver_s *dev)
{
- return usbh_rndis_eth_output(g_rndis_dev.netdev.d_buf, g_rndis_dev.netdev.d_len);
+ usbh_net_eth_output_common(&g_rndis_dev, usbh_rndis_get_eth_txbuf());
+ return usbh_rndis_eth_output(g_rndis_dev.netdev.d_len);
}
static void rndis_txavail_work(void *arg)
diff --git a/platform/rtthread/usbh_lwip.c b/platform/rtthread/usbh_lwip.c
index 2c0c7eaf..360a8489 100644
--- a/platform/rtthread/usbh_lwip.c
+++ b/platform/rtthread/usbh_lwip.c
@@ -32,11 +32,11 @@
#warning suggest you to enable LWIP_NO_TX_THREAD, we do not use rtthread eth tx thread
#endif
-#if LWIP_TCPIP_CORE_LOCKING_INPUT !=1
+#if LWIP_TCPIP_CORE_LOCKING_INPUT != 1
#warning suggest you to set LWIP_TCPIP_CORE_LOCKING_INPUT to 1, usb handles eth input with own thread
#endif
-#if LWIP_TCPIP_CORE_LOCKING !=1
+#if LWIP_TCPIP_CORE_LOCKING != 1
#error must set LWIP_TCPIP_CORE_LOCKING to 1
#endif
@@ -50,6 +50,18 @@
// #define CONFIG_USBHOST_PLATFORM_ASIX
// #define CONFIG_USBHOST_PLATFORM_RTL8152
+void usbh_lwip_eth_output_common(struct pbuf *p, uint8_t *buf)
+{
+ struct pbuf *q;
+ uint8_t *buffer;
+
+ buffer = buf;
+ for (q = p; q != NULL; q = q->next) {
+ usb_memcpy(buffer, q->payload, q->len);
+ buffer += q->len;
+ }
+}
+
void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len)
{
#if LWIP_TCPIP_CORE_LOCKING_INPUT
@@ -65,7 +77,7 @@ void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len)
#if LWIP_TCPIP_CORE_LOCKING_INPUT
p->payload = buf;
#else
- memcpy(p->payload, buf, len);
+ usb_memcpy(p->payload, buf, len);
#endif
err = netif->input(p, netif);
if (err != ERR_OK) {
@@ -105,7 +117,10 @@ static rt_err_t rt_usbh_cdc_ecm_control(rt_device_t dev, int cmd, void *args)
static rt_err_t rt_usbh_cdc_ecm_eth_tx(rt_device_t dev, struct pbuf *p)
{
- int ret = usbh_cdc_ecm_eth_output(p->payload, p->tot_len);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_cdc_ecm_get_eth_txbuf());
+ ret = usbh_cdc_ecm_eth_output(p->tot_len);
if (ret < 0) {
return -RT_ERROR;
} else {
@@ -188,7 +203,10 @@ static rt_err_t rt_usbh_rndis_control(rt_device_t dev, int cmd, void *args)
static rt_err_t rt_usbh_rndis_eth_tx(rt_device_t dev, struct pbuf *p)
{
- int ret = usbh_rndis_eth_output(p->payload, p->tot_len);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_rndis_get_eth_txbuf());
+ ret = usbh_rndis_eth_output(p->tot_len);
if (ret < 0) {
return -RT_ERROR;
} else {
@@ -254,7 +272,10 @@ static rt_err_t rt_usbh_cdc_ncm_control(rt_device_t dev, int cmd, void *args)
static rt_err_t rt_usbh_cdc_ncm_eth_tx(rt_device_t dev, struct pbuf *p)
{
- int ret = usbh_cdc_ncm_eth_output(p->payload, p->tot_len);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_cdc_ncm_get_eth_txbuf());
+ ret = usbh_cdc_ncm_eth_output(p->tot_len);
if (ret < 0) {
return -RT_ERROR;
} else {
@@ -317,7 +338,10 @@ static rt_err_t rt_usbh_asix_control(rt_device_t dev, int cmd, void *args)
static rt_err_t rt_usbh_asix_eth_tx(rt_device_t dev, struct pbuf *p)
{
- int ret = usbh_asix_eth_output(p->payload, p->tot_len);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_asix_get_eth_txbuf());
+ ret = usbh_asix_eth_output(p->tot_len);
if (ret < 0) {
return -RT_ERROR;
} else {
@@ -380,7 +404,10 @@ static rt_err_t rt_usbh_rtl8152_control(rt_device_t dev, int cmd, void *args)
static rt_err_t rt_usbh_rtl8152_eth_tx(rt_device_t dev, struct pbuf *p)
{
- int ret = usbh_rtl8152_eth_output(p->payload, p->tot_len);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_rtl8152_get_eth_txbuf());
+ ret = usbh_rtl8152_eth_output(p->tot_len);
if (ret < 0) {
return -RT_ERROR;
} else {