summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Kirchner <ralf.kirchner@embedded-brains.de>2014-03-14 15:06:43 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-03-14 16:01:33 +0100
commit5dc268f96d5576ac6e724a28d0b2332af6a8948f (patch)
tree47e0918996ef8dc6508646ecc3b337f2b00eab48
parentfac9da635b54fc986637c6615eef4819e6b1a3b3 (diff)
downloadrtems-5dc268f96d5576ac6e724a28d0b2332af6a8948f.tar.bz2
libchip: Relax buffer counts and add fatal error
-rw-r--r--c/src/lib/libbsp/shared/include/fatal.h5
-rw-r--r--c/src/libchip/network/dwmac.c15
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 a2b90e8ba9..2ba295d07b 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 06356436e5..ce2fa17e67 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,