From d8a657a88d567d0d10b8820cf2ab6aad7b8e26f4 Mon Sep 17 00:00:00 2001 From: Epagris Date: Tue, 23 Apr 2024 10:57:04 +0200 Subject: [PATCH] - ethinf transmit queue full notification added --- eth_interface.c | 63 ++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/eth_interface.c b/eth_interface.c index cbdad80..b4c0010 100644 --- a/eth_interface.c +++ b/eth_interface.c @@ -85,35 +85,35 @@ static ThreadReturnType task_ethintf(ThreadParamType param) { // act accordingly... switch (event_code) { - case ETH_IIE_RECV_NOTIFY: { - intf->ioDef->llRxRead(intf->ioDef); // read packets, will invoke RxStore - while (mq_avail(intf->rxQ) > 0) { - RawPckt rawPckt = mq_top(intf->rxQ); - mq_pop(intf->rxQ); - packsieve_input(&intf->sieve, &rawPckt); + case ETH_IIE_RECV_NOTIFY: { + intf->ioDef->llRxRead(intf->ioDef); // read packets, will invoke RxStore + while (mq_avail(intf->rxQ) > 0) { + RawPckt rawPckt = mq_top(intf->rxQ); + mq_pop(intf->rxQ); + packsieve_input(&intf->sieve, &rawPckt); + } + + } break; + case ETH_IIE_LINK_CHG_NOTIFY: { + bool ls = event_data; + ethinf_set_link_state(intf, ls); + + if (intf->dhcp != NULL) { + if (ls) { // if link is on + dhcp_start(intf->dhcp); + } else { // if link is off + dhcp_stop(intf->dhcp); } + } - } break; - case ETH_IIE_LINK_CHG_NOTIFY: { - bool ls = event_data; - ethinf_set_link_state(intf, ls); - - if (intf->dhcp != NULL) { - if (ls) { // if link is on - dhcp_start(intf->dhcp); - } else { // if link is off - dhcp_stop(intf->dhcp); - } - } - - MSG("ETH LINK: %s%s\n", (ls ? (ANSI_COLOR_BGREEN "UP") : (ANSI_COLOR_BRED "DOWN")), ANSI_COLOR_RESET); - } break; - case ETH_IIE_TRANSMIT_NOTIFY: { - intf->ioDef->llTxTrigger(intf->ioDef, intf->txQ); - } break; - default: - MSG("UNKNOWN event!\n"); - break; + MSG("ETH LINK: %s%s\n", (ls ? (ANSI_COLOR_BGREEN "UP") : (ANSI_COLOR_BRED "DOWN")), ANSI_COLOR_RESET); + } break; + case ETH_IIE_TRANSMIT_NOTIFY: { + intf->ioDef->llTxTrigger(intf->ioDef, intf->txQ); + } break; + default: + MSG("UNKNOWN event!\n"); + break; } } } @@ -127,8 +127,11 @@ void ethinf_receive(EthInterface *intf, const RawPckt *rawPckt) { } void ethinf_transmit(EthInterface *intf, const RawPckt *rawPckt) { - mq_push(intf->txQ, rawPckt); // push packet onto the message queue - ethinf_push_notification(intf, ETH_IIE_TRANSMIT_NOTIFY, 0); // notify processing thread of the peding transmit + if (mq_push(intf->txQ, rawPckt)) { // push packet onto the message queue + ethinf_push_notification(intf, ETH_IIE_TRANSMIT_NOTIFY, 0); // notify processing thread of the peding transmit + } else { + ERROR("Interface transmit queue full!\n"); + } } void ethinf_push_notification(EthInterface *intf, uint16_t event_code, uint16_t event_data) { @@ -148,7 +151,7 @@ void ethinf_pull_notification(EthInterface *intf, uint16_t *event_code, uint16_t *event_code = cpd & 0xFFFF; *event_data = (cpd >> 16) & 0xFFFF; - //MSG("EC: %d\n", *event_code); + // MSG("EC: %d\n", *event_code); } void ethinf_set_capabilities(EthInterface *intf, uint32_t cap) {