[rtems commit] libchip: Relax buffer counts and add fatal error
Sebastian Huber
sebh at rtems.org
Fri Mar 14 14:59:46 UTC 2014
Module: rtems
Branch: master
Commit: 5dc268f96d5576ac6e724a28d0b2332af6a8948f
Changeset: http://git.rtems.org/rtems/commit/?id=5dc268f96d5576ac6e724a28d0b2332af6a8948f
Author: Ralf Kirchner <ralf.kirchner at embedded-brains.de>
Date: Fri Mar 14 15:06:43 2014 +0100
libchip: Relax buffer counts and add fatal error
---
c/src/lib/libbsp/shared/include/fatal.h | 5 ++++-
c/src/libchip/network/dwmac.c | 15 +++++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/c/src/lib/libbsp/shared/include/fatal.h b/c/src/lib/libbsp/shared/include/fatal.h
index a2b90e8..2ba295d 100644
--- a/c/src/lib/libbsp/shared/include/fatal.h
+++ b/c/src/lib/libbsp/shared/include/fatal.h
@@ -98,7 +98,10 @@ typedef enum {
MRM332_FATAL_SPURIOUS_INTERRUPT = BSP_FATAL_CODE_BLOCK(6),
/* PowerPC fatal codes */
- PPC_FATAL_EXCEPTION_INITIALIZATION = BSP_FATAL_CODE_BLOCK(7)
+ PPC_FATAL_EXCEPTION_INITIALIZATION = BSP_FATAL_CODE_BLOCK(7),
+
+ /* Libchip fatal codes */
+ DWMAC_FATAL_TOO_MANY_RBUFS_CONFIGURED = BSP_FATAL_CODE_BLOCK(8)
} bsp_fatal_code;
RTEMS_COMPILER_NO_RETURN_ATTRIBUTE static inline void
diff --git a/c/src/libchip/network/dwmac.c b/c/src/libchip/network/dwmac.c
index 0635643..ce2fa17 100644
--- a/c/src/libchip/network/dwmac.c
+++ b/c/src/libchip/network/dwmac.c
@@ -27,6 +27,7 @@
#include <string.h>
#include <errno.h>
#include <bsp.h>
+#include <bsp/fatal.h>
#include <rtems/endian.h>
#include "dwmac-common.h"
#include "dwmac-core.h"
@@ -47,9 +48,9 @@ const dwmac_phy_event PHY_EVENT_REMOTE_FAULT = 0x02;
const dwmac_phy_event PHY_EVENT_LINK_UP = 0x01;
/* Default values for the number of DMA descriptors and mbufs to be used */
-#define DWMAC_CONFIG_RX_UNIT_COUNT_DEFAULT 256
+#define DWMAC_CONFIG_RX_UNIT_COUNT_DEFAULT 64
#define DWMAC_CONFIG_RX_UNIT_COUNT_MAX INT_MAX
-#define DWMAC_CONFIG_TX_UNIT_COUNT_DEFAULT 256
+#define DWMAC_CONFIG_TX_UNIT_COUNT_DEFAULT 64
#define DWMAC_CONFIG_TX_UNIT_COUNT_MAX INT_MAX
/* Default values for the DMA configuration */
@@ -96,6 +97,9 @@ const dwmac_phy_event PHY_EVENT_LINK_UP = 0x01;
#define DWMAC_DMA_THRESHOLD_CONTROL_DEFAULT 64
+#define DWMAC_GLOBAL_MBUF_CNT (rtems_bsdnet_config.mbuf_bytecount / sizeof(struct mbuf))
+#define DWMAG_GLOBAL_MCLUST_CNT (rtems_bsdnet_config.mbuf_cluster_bytecount / MCLBYTES)
+
static int dwmac_if_mdio_busy_wait( const volatile uint32_t *gmii_address )
{
rtems_interval timeout = rtems_clock_get_ticks_per_second();
@@ -2168,6 +2172,13 @@ static int dwmac_if_attach(
DWMAC_CONFIG_TX_UNIT_COUNT_MAX
);
+ if (
+ DWMAC_GLOBAL_MBUF_CNT / 4 < bsd_config->rbuf_count
+ || DWMAG_GLOBAL_MCLUST_CNT / 4 < bsd_config->rbuf_count
+ ) {
+ bsp_fatal( DWMAC_FATAL_TOO_MANY_RBUFS_CONFIGURED );
+ }
+
/* Copy MAC address */
memcpy(
self->arpcom.ac_enaddr,
More information about the vc
mailing list