|
|
@@ -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 {
|