fix: idk
This commit is contained in:
@@ -70,6 +70,15 @@ err_t ethernetif_init(struct netif* netif) {
|
||||
static err_t low_level_output(struct netif* netif, struct pbuf* p) {
|
||||
(void)netif;
|
||||
|
||||
// single-segment pbuf
|
||||
if (p->next == NULL && p->len <= ETH_TX_BUF_SIZE) {
|
||||
if (eth_send_packet(p->payload, p->len) == 0) {
|
||||
LINK_STATS_INC(link.xmit);
|
||||
return ERR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// chain of pbufs
|
||||
static uint8_t tx_buffer[ETH_TX_BUF_SIZE];
|
||||
uint32_t total_len = 0;
|
||||
|
||||
@@ -82,21 +91,13 @@ static err_t low_level_output(struct netif* netif, struct pbuf* p) {
|
||||
total_len += q->len;
|
||||
}
|
||||
|
||||
// send packet via driver
|
||||
int result = eth_send_packet(tx_buffer, total_len);
|
||||
|
||||
if (result == -1) {
|
||||
// tx queue full
|
||||
LINK_STATS_INC(link.drop);
|
||||
return ERR_BUF;
|
||||
} else if (result == -2) {
|
||||
// invalid length
|
||||
LINK_STATS_INC(link.err);
|
||||
return ERR_ARG;
|
||||
if (eth_send_packet(tx_buffer, total_len) == 0) {
|
||||
LINK_STATS_INC(link.xmit);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
LINK_STATS_INC(link.xmit);
|
||||
return ERR_OK;
|
||||
LINK_STATS_INC(link.drop);
|
||||
return ERR_BUF;
|
||||
}
|
||||
|
||||
void ethernetif_input(struct netif* netif) {
|
||||
@@ -108,13 +109,8 @@ void ethernetif_input(struct netif* netif) {
|
||||
struct pbuf* p = pbuf_alloc(PBUF_RAW, length, PBUF_POOL);
|
||||
|
||||
if (p != NULL) {
|
||||
// copy packet into pbuf chain
|
||||
uint32_t offset = 0;
|
||||
for (struct pbuf* q = p; q != NULL; q = q->next) {
|
||||
memcpy(q->payload, packet + offset, q->len);
|
||||
offset += q->len;
|
||||
}
|
||||
|
||||
// usually contiguous in PBUF_POOL
|
||||
pbuf_take(p, packet, length);
|
||||
LINK_STATS_INC(link.recv);
|
||||
|
||||
// pass to lwIP
|
||||
|
||||
Reference in New Issue
Block a user