tweak lwipopts.h

This commit is contained in:
2025-11-09 20:24:50 +06:00
parent a0ca17e68f
commit fd3d66e424
7 changed files with 34 additions and 44 deletions

View File

@@ -13,7 +13,7 @@
#define IFNAME0 'e'
#define IFNAME1 'n'
#define ETH_RX_BUF_COUNT 2
#define ETH_RX_BUF_COUNT 4
#define ETH_TX_BUF_COUNT 2
/* buf size should be at least ETH_MAX_PACKET_SIZE */
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE
@@ -58,8 +58,8 @@ static inline void tx_queue_produce(tx_queue_t* q) {
}
}
static inline void tx_queue_consume(tx_queue_t* q) {
q->is_full = false;
q->tail = (q->tail + 1) % ETH_TX_BUF_COUNT;
q->is_full = false;
}
static void low_level_init(struct netif* netif);
@@ -200,11 +200,11 @@ static err_t low_level_output(struct netif* netif, struct pbuf* p) {
struct ethernetif* ethernetif = netif->state;
err_t errval = ERR_OK;
NVIC_DisableIRQ(ETH_IRQn);
if (tx_queue_is_full(&ethernetif->tx_q)) {
// should this be ERR_BUF or ERR_MEM? does ERR_MEM re-queue the packet?
// queue full, drop pkt
errval = ERR_BUF;
// errval = ERR_MEM;
} else {
uint32_t current_idx = ethernetif->tx_q.head;
uint8_t* tx_buf_ptr = (uint8_t*)g_dma_tx_descs[current_idx].Buffer1Addr;
@@ -218,19 +218,10 @@ static err_t low_level_output(struct netif* netif, struct pbuf* p) {
g_dma_tx_descs[current_idx].Status = len;
tx_queue_produce(&ethernetif->tx_q);
LINK_STATS_INC(link.xmit);
MIB2_STATS_NETIF_ADD(netif, ifoutoctets, len);
}
tx_start_if_possible();
NVIC_EnableIRQ(ETH_IRQn);
if (errval == ERR_BUF) {
LINK_STATS_INC(link.drop);
}
return errval;
}
@@ -332,8 +323,10 @@ void ETH_IRQHandler(void) {
ETH10M->EIR = RB_ETH_EIR_TXIF;
if (!tx_queue_is_empty(&ethernetif->tx_q)) {
LINK_STATS_INC(link.xmit);
tx_queue_consume(&ethernetif->tx_q);
}
tx_start_if_possible();
}