Nios® V Embedded Processor Design Handbook

ID 726952
Date 12/04/2023
Document Table of Contents
Give Feedback Network Interface Configuration

µC/TCP-IP stores received and transmitted data in network buffers (also referred as receive buffers and transmit buffers). The size of these network buffers should fulfill the minimum and maximum packet frame sizes of the network interfaces.

Based on the µC/TCP-IP application requirements, configure the network buffers to better suit your needs in software/app/uc_tcp_ip_init.c source code. The following are the configurable network buffers:
  • Receive Large Buffer
  • Transmit Large Buffer
  • Transmit Small Buffer

While it is best to leave the size of large buffers at maximum frame size, you can lower the size of the small buffers to reduce the system's RAM usage, further improving the system performance. Additionally, you can configure the number of receive and transmit buffers allocated to the device. Keep in mind that you need to have at least one buffer given for each network.

After configuring the network buffers, register them to a valid memory locations, either the main system memory or a dedicated descriptor memory. If you are using a dedicated descriptor memory, define the starting address and memory span of the descriptor memory in the source code.

Refer to Network Buffers Configuration Table for the µC/TCP-IP example designs default configuration. A dedicated descriptor memory is provided in the hardware system, and registered to the receive buffers. Transmit buffers are routed to the main memory.

Note: Intel recommends receive buffers to hold up to the maximum frame size because the size of data received is unknown to the device. Alternatively, the size of data transmitted is known to the device, making it possible to use small transmit buffers when the transmitted data is smaller than the maximum frame size. Thus, allowing receive buffers to use large buffers only, while transmit buffers use both large and small buffers.
Table 37.  Network Buffers Configuration
Settings Description Default Value
.RxBufPoolType Memory location for the receive data buffers. 6 7 NET_IF_MEM_TYPE_DEDICATED
.RxBufLargeNbr Number of receive buffers allocated to the device. NUM_RX_BUFFERS 8
.TxBufPoolType Memory location for the transmit data buffers. 6 7 NET_IF_MEM_TYPE_MAIN
.TxBufLargeNbr Number of transmit buffers allocated to the device. 5u
.TxBufSmallSize Size of the small transmit buffers. 60u
.TxBufSmallNbr Number of small transmit buffers allocated to the device. 5u
.MemAddr Starting address of the dedicated descriptor memory.9 SYS_DESC_MEM_BASE
.MemSize Size of the dedicated descriptor memory (in bytes). SYS_DESC_MEM_SPAN

Default network interface configuration in uc_tcp_ip_init.c

static const CPU_INT08U NUM_RX_LISTS = 2;

static NET_DEV_CFG_ETHER NetDev_Cfg_Ether_TSE = {

    .RxBufPoolType    = NET_IF_MEM_TYPE_DEDICATED,
    .RxBufLargeSize   = 1536u,
    .RxBufLargeNbr    = NUM_RX_BUFFERS,
    .RxBufAlignOctets = 4u,
    .RxBufIxOffset    = 2u,

    .TxBufPoolType    = NET_IF_MEM_TYPE_MAIN,
    .TxBufLargeSize   = 1518u,
    .TxBufLargeNbr    = 5u,
    .TxBufSmallSize   = 60u,
    .TxBufSmallNbr    = 5u,
    .TxBufAlignOctets = 4u,
    .TxBufIxOffset    = 0u,

    .MemAddr    = SYS_DESC_MEM_BASE,
    .MemSize    = SYS_DESC_MEM_SPAN,

    .Flags =  NET_DEV_CFG_FLAG_NONE,

    .RxDescNbr = 8u, // NOTE: Not configurable.
    .TxDescNbr = 1u, // NOTE: Not configurable.
    .BaseAddr           = 0,
    .DataBusSizeNbrBits = 0,

    .HW_AddrStr = "",
6 This field must be set to either NET_IF_MEM_TYPE_MAIN for main memory or NET_IF_MEM_TYPE_DEDICATED for dedicated descriptor memory.
7 Only one buffer type (receive or transmit buffers) can be set to NET_IF_MEM_TYPE_DEDICATED.
8 This field is derived based on NUM_RX_LISTS and ALTERA_TSE_MSGDMA_RX_DESC_CHAIN_SIZE.
9 If there is no dedicated descriptor memory in the system, this field should be set to NULL