drivers/ethernet: Update RX error statistics relevantly
Update such statistic on all drivers. Also, remove TX stats in native and stellaris drivers: such update is done in L2 now. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
952e494bdd
commit
8a8d4d3070
8 changed files with 44 additions and 84 deletions
|
@ -22,6 +22,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|||
#include <string.h>
|
||||
#include <sys_io.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <ethernet/eth_stats.h>
|
||||
|
||||
#include "eth_dw_priv.h"
|
||||
|
||||
|
@ -80,7 +81,7 @@ static void eth_rx(struct device *dev)
|
|||
*/
|
||||
if (frm_len < sizeof(u32_t)) {
|
||||
LOG_ERR("Frame too small: %u", frm_len);
|
||||
goto release_desc;
|
||||
goto error;
|
||||
} else {
|
||||
frm_len -= sizeof(u32_t);
|
||||
}
|
||||
|
@ -88,22 +89,26 @@ static void eth_rx(struct device *dev)
|
|||
pkt = net_pkt_get_reserve_rx(0, K_NO_WAIT);
|
||||
if (!pkt) {
|
||||
LOG_ERR("Failed to obtain RX buffer");
|
||||
goto release_desc;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!net_pkt_append_all(pkt, frm_len, (u8_t *)context->rx_buf,
|
||||
K_NO_WAIT)) {
|
||||
LOG_ERR("Failed to append RX buffer to context buffer");
|
||||
net_pkt_unref(pkt);
|
||||
goto release_desc;
|
||||
goto error;
|
||||
}
|
||||
|
||||
r = net_recv_data(context->iface, pkt);
|
||||
if (r < 0) {
|
||||
LOG_ERR("Failed to enqueue frame into RX queue: %d", r);
|
||||
net_pkt_unref(pkt);
|
||||
goto error;
|
||||
}
|
||||
|
||||
goto release_desc;
|
||||
error:
|
||||
eth_stats_update_errors_rx(context->iface);
|
||||
release_desc:
|
||||
/* Return ownership of the RX descriptor to the device. */
|
||||
context->rx_desc.own = 1U;
|
||||
|
|
|
@ -11,6 +11,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|||
|
||||
#include <zephyr.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <ethernet/eth_stats.h>
|
||||
#include <pci/pci.h>
|
||||
#include "eth_e1000_priv.h"
|
||||
|
||||
|
@ -132,6 +133,8 @@ static void e1000_isr(struct device *device)
|
|||
|
||||
if (pkt) {
|
||||
net_recv_data(dev->iface, pkt);
|
||||
} else {
|
||||
eth_stats_update_errors_rx(dev->iface);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <ethernet/eth_stats.h>
|
||||
|
||||
#include "eth_enc28j60_priv.h"
|
||||
|
||||
|
@ -553,6 +554,7 @@ static int eth_enc28j60_rx(struct device *dev)
|
|||
pkt = net_pkt_get_reserve_rx(0, config->timeout);
|
||||
if (!pkt) {
|
||||
LOG_ERR("Could not allocate rx buffer");
|
||||
eth_stats_update_errors_rx(context->iface);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -565,6 +567,7 @@ static int eth_enc28j60_rx(struct device *dev)
|
|||
pkt_buf = net_pkt_get_frag(pkt, config->timeout);
|
||||
if (!pkt_buf) {
|
||||
LOG_ERR("Could not allocate data buffer");
|
||||
eth_stats_update_errors_rx(context->iface);
|
||||
net_pkt_unref(pkt);
|
||||
|
||||
goto done;
|
||||
|
|
|
@ -25,6 +25,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <ethernet/eth_stats.h>
|
||||
|
||||
#if defined(CONFIG_PTP_CLOCK_MCUX)
|
||||
#include <ptp_clock.h>
|
||||
|
@ -550,36 +551,18 @@ static void eth_rx(struct device *iface)
|
|||
|
||||
ENET_GetRxErrBeforeReadFrame(&context->enet_handle,
|
||||
&error_stats);
|
||||
/* Flush the current read buffer. This operation can
|
||||
* only report failure if there is no frame to flush,
|
||||
* which cannot happen in this context.
|
||||
*/
|
||||
status = ENET_ReadFrame(ENET, &context->enet_handle, NULL, 0);
|
||||
assert(status == kStatus_Success);
|
||||
return;
|
||||
goto flush;
|
||||
}
|
||||
|
||||
pkt = net_pkt_get_reserve_rx(0, K_NO_WAIT);
|
||||
if (!pkt) {
|
||||
/* We failed to get a receive buffer. We don't add
|
||||
* any further logging here because the allocator
|
||||
* issued a diagnostic when it failed to allocate.
|
||||
*
|
||||
* Flush the current read buffer. This operation can
|
||||
* only report failure if there is no frame to flush,
|
||||
* which cannot happen in this context.
|
||||
*/
|
||||
status = ENET_ReadFrame(ENET, &context->enet_handle, NULL, 0);
|
||||
assert(status == kStatus_Success);
|
||||
return;
|
||||
goto flush;
|
||||
}
|
||||
|
||||
if (sizeof(context->frame_buf) < frame_length) {
|
||||
LOG_ERR("frame too large (%d)", frame_length);
|
||||
net_pkt_unref(pkt);
|
||||
status = ENET_ReadFrame(ENET, &context->enet_handle, NULL, 0);
|
||||
assert(status == kStatus_Success);
|
||||
return;
|
||||
goto flush;
|
||||
}
|
||||
|
||||
/* As context->frame_buf is shared resource used by both eth_tx
|
||||
|
@ -593,7 +576,7 @@ static void eth_rx(struct device *iface)
|
|||
irq_unlock(imask);
|
||||
LOG_ERR("ENET_ReadFrame failed: %d", (int)status);
|
||||
net_pkt_unref(pkt);
|
||||
return;
|
||||
goto error;
|
||||
}
|
||||
|
||||
src = context->frame_buf;
|
||||
|
@ -608,7 +591,7 @@ static void eth_rx(struct device *iface)
|
|||
LOG_ERR("Failed to get fragment buf");
|
||||
net_pkt_unref(pkt);
|
||||
assert(status == kStatus_Success);
|
||||
return;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!prev_buf) {
|
||||
|
@ -672,7 +655,19 @@ static void eth_rx(struct device *iface)
|
|||
|
||||
if (net_recv_data(get_iface(context, vlan_tag), pkt) < 0) {
|
||||
net_pkt_unref(pkt);
|
||||
goto error;
|
||||
}
|
||||
|
||||
return;
|
||||
flush:
|
||||
/* Flush the current read buffer. This operation can
|
||||
* only report failure if there is no frame to flush,
|
||||
* which cannot happen in this context.
|
||||
*/
|
||||
status = ENET_ReadFrame(ENET, &context->enet_handle, NULL, 0);
|
||||
assert(status == kStatus_Success);
|
||||
error:
|
||||
eth_stats_update_errors_rx(get_iface(context, vlan_tag));
|
||||
}
|
||||
|
||||
#if defined(CONFIG_PTP_CLOCK_MCUX)
|
||||
|
|
|
@ -29,12 +29,12 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|||
#include <net/net_core.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <ethernet/eth_stats.h>
|
||||
|
||||
#include <ptp_clock.h>
|
||||
#include <net/gptp.h>
|
||||
|
||||
#include "eth_native_posix_priv.h"
|
||||
#include "ethernet/eth_stats.h"
|
||||
|
||||
#if defined(CONFIG_NET_L2_ETHERNET)
|
||||
#define _ETH_MTU 1500
|
||||
|
@ -218,20 +218,6 @@ static int eth_send(struct device *dev, struct net_pkt *pkt)
|
|||
frag = frag->frags;
|
||||
}
|
||||
|
||||
eth_stats_update_bytes_tx(net_pkt_iface(pkt), count);
|
||||
eth_stats_update_pkts_tx(net_pkt_iface(pkt));
|
||||
|
||||
if (IS_ENABLED(CONFIG_NET_STATISTICS_ETHERNET)) {
|
||||
if (net_eth_is_addr_broadcast(
|
||||
&((struct net_eth_hdr *)NET_ETH_HDR(pkt))->dst)) {
|
||||
eth_stats_update_broadcast_tx(net_pkt_iface(pkt));
|
||||
} else if (net_eth_is_addr_multicast(
|
||||
&((struct net_eth_hdr *)
|
||||
NET_ETH_HDR(pkt))->dst)) {
|
||||
eth_stats_update_multicast_tx(net_pkt_iface(pkt));
|
||||
}
|
||||
}
|
||||
|
||||
update_gptp(net_pkt_iface(pkt), pkt, true);
|
||||
|
||||
LOG_DBG("Send pkt %p len %d", pkt, count);
|
||||
|
@ -338,20 +324,6 @@ static int read_data(struct eth_context *ctx, int fd)
|
|||
iface = get_iface(ctx, vlan_tag);
|
||||
pkt_len = net_pkt_get_len(pkt);
|
||||
|
||||
eth_stats_update_bytes_rx(iface, pkt_len);
|
||||
eth_stats_update_pkts_rx(iface);
|
||||
|
||||
if (IS_ENABLED(CONFIG_NET_STATISTICS_ETHERNET)) {
|
||||
if (net_eth_is_addr_broadcast(
|
||||
&((struct net_eth_hdr *)NET_ETH_HDR(pkt))->dst)) {
|
||||
eth_stats_update_broadcast_rx(iface);
|
||||
} else if (net_eth_is_addr_multicast(
|
||||
&((struct net_eth_hdr *)
|
||||
NET_ETH_HDR(pkt))->dst)) {
|
||||
eth_stats_update_multicast_rx(iface);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DBG("Recv pkt %p len %d", pkt, pkt_len);
|
||||
|
||||
update_gptp(iface, pkt, false);
|
||||
|
@ -374,6 +346,8 @@ static void eth_rx(struct eth_context *ctx)
|
|||
ret = eth_wait_data(ctx->dev_fd);
|
||||
if (!ret) {
|
||||
read_data(ctx, ctx->dev_fd);
|
||||
} else {
|
||||
eth_stats_update_errors_rx(ctx->iface);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <ethernet/eth_stats.h>
|
||||
#include <i2c.h>
|
||||
#include <soc.h>
|
||||
#include "phy_sam_gmac.h"
|
||||
|
@ -1263,6 +1264,8 @@ static void eth_rx(struct gmac_queue *queue)
|
|||
|
||||
if (net_recv_data(get_iface(dev_data, vlan_tag),
|
||||
rx_frame) < 0) {
|
||||
eth_stats_update_errors_rx(get_iface(dev_data,
|
||||
vlan_tag));
|
||||
net_pkt_unref(rx_frame);
|
||||
}
|
||||
|
||||
|
|
|
@ -101,21 +101,6 @@ static int eth_stellaris_send(struct device *dev, struct net_pkt *pkt)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_NET_STATISTICS_ETHERNET)) {
|
||||
struct net_eth_hdr *pkt_hdr;
|
||||
|
||||
/* Update statistics counters */
|
||||
eth_stats_update_bytes_tx(net_pkt_iface(pkt),
|
||||
data_len);
|
||||
eth_stats_update_pkts_tx(net_pkt_iface(pkt));
|
||||
pkt_hdr = NET_ETH_HDR(pkt);
|
||||
if (net_eth_is_addr_multicast(&pkt_hdr->dst)) {
|
||||
eth_stats_update_multicast_tx(net_pkt_iface(pkt));
|
||||
} else if (net_eth_is_addr_broadcast(&pkt_hdr->dst)) {
|
||||
eth_stats_update_broadcast_tx(net_pkt_iface(pkt));
|
||||
}
|
||||
}
|
||||
|
||||
LOG_DBG("pkt sent %p len %d", pkt, data_len);
|
||||
|
||||
return 0;
|
||||
|
@ -233,20 +218,6 @@ static void eth_stellaris_rx(struct device *dev)
|
|||
goto pkt_unref;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_NET_STATISTICS_ETHERNET)) {
|
||||
struct net_eth_hdr *pkt_hdr;
|
||||
|
||||
/* Update statistics counters */
|
||||
eth_stats_update_bytes_rx(iface, frame_len - 6);
|
||||
eth_stats_update_pkts_rx(iface);
|
||||
pkt_hdr = NET_ETH_HDR(pkt);
|
||||
if (net_eth_is_addr_broadcast(&pkt_hdr->dst)) {
|
||||
eth_stats_update_broadcast_rx(iface);
|
||||
} else if (net_eth_is_addr_multicast(&pkt_hdr->dst)) {
|
||||
eth_stats_update_multicast_rx(iface);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
pkt_unref:
|
||||
|
|
|
@ -18,6 +18,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
|
|||
#include <net/net_pkt.h>
|
||||
#include <net/net_if.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <ethernet/eth_stats.h>
|
||||
#include <soc.h>
|
||||
#include <misc/printk.h>
|
||||
#include <clock_control.h>
|
||||
|
@ -186,6 +187,10 @@ release_desc:
|
|||
heth->Instance->DMARPDR = 0;
|
||||
}
|
||||
|
||||
if (!pkt) {
|
||||
eth_stats_update_errors_rx(dev_data->iface);
|
||||
}
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
||||
|
@ -212,6 +217,7 @@ static void rx_thread(void *arg1, void *unused1, void *unused2)
|
|||
net_pkt_print_frags(pkt);
|
||||
res = net_recv_data(dev_data->iface, pkt);
|
||||
if (res < 0) {
|
||||
eth_stats_update_errors_rx(dev_data->iface);
|
||||
LOG_ERR("Failed to enqueue frame "
|
||||
"into RX queue: %d", res);
|
||||
net_pkt_unref(pkt);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue