Soohwan Kim
Published © Apache-2.0

Network Performance of SoC with TCP/IP Offload Engine, W7500

TCP throughput of W7500(Cortex-M0 with TCP Offload Engine) are measured depending on RX buffer size, main bus clock and DMA.

AdvancedFull instructions provided1,633
Network Performance of SoC with TCP/IP Offload Engine, W7500

Things used in this project

Hardware components

W7500
WIZnet W7500
×1

Story

Read more

Code

Code

Plain text
// main.c 
/* External Clock */
CRG_PLL_InputFrequencySelect(CRG_OCLK);
//*(volatile uint32_t *)(0x41001014) = 0x000C0200; // 48MHz
//*(volatile uint32_t *)(0x41001014) = 0x000B0200; // 44MHz
//*(volatile uint32_t *)(0x41001014) = 0x000A0200; // 40MHz
//*(volatile uint32_t *)(0x41001014) = 0x00090200; // 36MHz
//*(volatile uint32_t *)(0x41001014) = 0x00080200; // 32MHz
//*(volatile uint32_t *)(0x41001014) = 0x00070200; // 28MHz
//*(volatile uint32_t *)(0x41001014) = 0x00060200; // 24MHzS
//*(volatile uint32_t *)(0x41001014) = 0x00050200; // 20MHz, Default
//*(volatile uint32_t *)(0x41001014) = 0x00040200; // 16MHz
//*(volatile uint32_t *)(0x41001014) = 0x00030200; // 12MHz
*(volatile uint32_t *)(0x41001014) = 0x00020200; //  8MHz

Code

Plain text
int32_t recvonly_tcps(uint8_t sn, uint8_t* buf, uint16_t port)
{
     int32_t ret;
     uint16_t size = 0;
     int32_t i;
     switch(getSn_SR(sn))
     {
        case SOCK_ESTABLISHED :
           if(getSn_IR(sn) & Sn_IR_CON)
           {
              setSn_IR(sn,Sn_IR_CON);
           }
           // Don't need to check SOCKERR_BUSY because it doesn't not occur.
           if((size = getSn_RX_RSR(sn)) > 0) 
           {
              if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE;
              printf("---------------size :%d\r\n", size);
             ret = recv(sn, buf, size);                 
           }
           break;
        case SOCK_CLOSE_WAIT :
           if( (ret = listen(sn)) != SOCK_OK) return ret;
           break;
        case SOCK_CLOSED:
           if((ret = socket(sn, Sn_MR_TCP, port, Sn_MR_ND)) != sn) return ret;
           break;
        default:
           break;
     }
     return 1;
}

Code

Plain text
  // main.c 
  /* set Sn_RXBUF_SIZE and Sn_RXBUF_SIZE as 8KB */
  uint8_t tx_size[8] = { 8, 0, 0, 0, 0, 0, 0, 0 };
  uint8_t rx_size[8] = { 8, 0, 0, 0, 0, 0, 0, 0 };

  ...

  /* Set Network Configuration */
  wizchip_init(tx_size, rx_size);

Code

Plain text
  /* DMA memory copy */
  uint32_t chnl_num  = 5 ;          //DMA Channel number
  unsigned int src = 0xXXXX_XXXX;   // Source Address
  unsigned int dest = 0xDDDD_DDDD ; // Destination Address
  unsigned int size = 0;            // byte operation
  unsigned int num = 1024;          // data length
  void dma_memory_copy (chnl_num, src, dest, size, num)

Code

Plain text
  //W7500x_wztoe.c
  #define _DEF_ACCESS_DMA_BUF_
  #ifdef _DEF_ACCESS_DMA_BUF_
  #include "W7500x_dma.h"
  #define MAX_TRANSNUM  1024
  void WIZCHIP_READ_DMA (uint32_t BaseAddr, uint16_t ptr, uint8_t* pBuf, uint16_t len)
  {
      /* call void dma_memory_copy () */
  }
  void WIZCHIP_WRITE_DMA(uint32_t BaseAddr, uint16_t ptr, uint8_t* pBuf, uint16_t len)
  {
      /* call void dma_memory_copy () */
  }
  ...

Code

Plain text
PHY is linked. 
MAC ADDRESS : 00:08:DC:01:02:03
IP ADDRESS : 192.168.077.009
GW ADDRESS : 192.168.077.001
SN MASK: 255.255.255.000
TEST- START 
0:Listen, TCP server loopback, port [5000]
0:Connected - 192.168.77.223 : 1110 // <-- dispaly after TCP_Established from Iperf

Code

Plain text
// main.c 
/* External Clock */
CRG_PLL_InputFrequencySelect(CRG_OCLK);
//*(volatile uint32_t *)(0x41001014) = 0x000C0200; // 48MHz
//*(volatile uint32_t *)(0x41001014) = 0x000B0200; // 44MHz
//*(volatile uint32_t *)(0x41001014) = 0x000A0200; // 40MHz
//*(volatile uint32_t *)(0x41001014) = 0x00090200; // 36MHz
//*(volatile uint32_t *)(0x41001014) = 0x00080200; // 32MHz
//*(volatile uint32_t *)(0x41001014) = 0x00070200; // 28MHz
//*(volatile uint32_t *)(0x41001014) = 0x00060200; // 24MHzS
//*(volatile uint32_t *)(0x41001014) = 0x00050200; // 20MHz, Default
//*(volatile uint32_t *)(0x41001014) = 0x00040200; // 16MHz
//*(volatile uint32_t *)(0x41001014) = 0x00030200; // 12MHz
*(volatile uint32_t *)(0x41001014) = 0x00020200; //  8MHz

Code

Plain text
int32_t recvonly_tcps(uint8_t sn, uint8_t* buf, uint16_t port)
{
     int32_t ret;
     uint16_t size = 0;
     int32_t i;
     switch(getSn_SR(sn))
     {
        case SOCK_ESTABLISHED :
           if(getSn_IR(sn) & Sn_IR_CON)
           {
              setSn_IR(sn,Sn_IR_CON);
           }
           // Don't need to check SOCKERR_BUSY because it doesn't not occur.
           if((size = getSn_RX_RSR(sn)) > 0) 
           {
              if(size > DATA_BUF_SIZE) size = DATA_BUF_SIZE;
              printf("---------------size :%d\r\n", size);
             ret = recv(sn, buf, size);                 
           }
           break;
        case SOCK_CLOSE_WAIT :
           if( (ret = listen(sn)) != SOCK_OK) return ret;
           break;
        case SOCK_CLOSED:
           if((ret = socket(sn, Sn_MR_TCP, port, Sn_MR_ND)) != sn) return ret;
           break;
        default:
           break;
     }
     return 1;
}

Code

Plain text
  // main.c 
  /* set Sn_RXBUF_SIZE and Sn_RXBUF_SIZE as 8KB */
  uint8_t tx_size[8] = { 8, 0, 0, 0, 0, 0, 0, 0 };
  uint8_t rx_size[8] = { 8, 0, 0, 0, 0, 0, 0, 0 };

  ...

  /* Set Network Configuration */
  wizchip_init(tx_size, rx_size);

Code

Plain text
  /* DMA memory copy */
  uint32_t chnl_num  = 5 ;          //DMA Channel number
  unsigned int src = 0xXXXX_XXXX;   // Source Address
  unsigned int dest = 0xDDDD_DDDD ; // Destination Address
  unsigned int size = 0;            // byte operation
  unsigned int num = 1024;          // data length
  void dma_memory_copy (chnl_num, src, dest, size, num)

Code

Plain text
  //W7500x_wztoe.c
  #define _DEF_ACCESS_DMA_BUF_
  #ifdef _DEF_ACCESS_DMA_BUF_
  #include "W7500x_dma.h"
  #define MAX_TRANSNUM  1024
  void WIZCHIP_READ_DMA (uint32_t BaseAddr, uint16_t ptr, uint8_t* pBuf, uint16_t len)
  {
      /* call void dma_memory_copy () */
  }
  void WIZCHIP_WRITE_DMA(uint32_t BaseAddr, uint16_t ptr, uint8_t* pBuf, uint16_t len)
  {
      /* call void dma_memory_copy () */
  }
  ...

Code

Plain text
PHY is linked. 
MAC ADDRESS : 00:08:DC:01:02:03
IP ADDRESS : 192.168.077.009
GW ADDRESS : 192.168.077.001
SN MASK: 255.255.255.000
TEST- START 
0:Listen, TCP server loopback, port [5000]
0:Connected - 192.168.77.223 : 1110 // <-- dispaly after TCP_Established from Iperf

Github file

https://www.blogger.com/[https://github.com/embeddist/W7500/tree/W7500_DMA

Credits

Soohwan Kim

Soohwan Kim

6 projects • 7 followers
Embedded System, ARM mbed, Arduino, TCP/IP, SoC, Open Source Hardware

Comments