refactor(platform): add usbh_xxx_get_eth_txbuf api, especially for lwip pbuf list

This commit is contained in:
sakumisu
2024-06-25 17:18:09 +08:00
parent 31cd834ded
commit 6c92681e48
13 changed files with 127 additions and 54 deletions

View File

@@ -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];

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);