Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Contributor
samarawickrama
Posts: 49
Registered: ‎09-04-2011
0
Accepted Solution

lwIP : Write data from FPGA to PC (ETHERNET RAW APIs) ...

Hi,

 

I setup ML605_IwIP_AXI reference design for ETHERNET and successfully connected to iperf server.

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

+++++ lwIP RAW Mode  +++++
Board IP:       192.168.1.10
Netmask :       255.255.255.0
Gateway :       192.168.1.1
auto-negotiated link speed: 1000

              Server   Port Connect With..
-------------------- ------ --------------------
         echo server      7 $ telnet <board_ip> 7
       rxperf server   5001 $ iperf -c <board ip> -i 5 -t 100
       txperf client    N/A $ iperf -s -i 5 -t 100 (on host with IP 192.168.1.100)
         tftp server     69 $ tftp -i 192.168.1.10 PUT <source-file>
         http server     80 Point your web browser to http://192.168.1.10

txperf: Connected to iperf server

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

Now I need to send data from FPGA to PC.

 

1) What are the APIs I should use?

2) How to write data to send buffer?

3) Are there any sample codes to do this?

 

I need to use RAW APIs.

 

Thank you.

Contributor
samarawickrama
Posts: 49
Registered: ‎09-04-2011

Re: lwIP : Write data from FPGA to PC (ETHERNET RAW APIs) ...

Hi,

 

OK ... the problem can be solved by following the steps below,

 

Link : http://lwip.wikia.com/wiki/Raw/TCP

 

To send data on a TCP connection:

  1. Call tcp_sent() to specify a callback function for acknowledgements.
  2. Call tcp_sndbuf() to find the maximum amount of data that can be sent.
  3. Call tcp_write() to enqueue the data.
  4. Call tcp_output() to force the data to be sent.
u16_t tcp_sndbuf(struct tcp_pcb * pcb)

Returns the number of bytes of space available in the output queue.

err_t tcp_write(struct tcp_pcb * pcb, void * dataptr, u16_t len,
                 u8_t apiflags)

Enqueues the data pointed to by the argument dataptr. The length of the data is passed as the len parameter.

The apiflags argument can have either of the following bits:

  • TCP_WRITE_FLAG_COPY indicates that lwIP should allocate new memory and copy the data into it. If not specified, no new memory should be allocated and the data should only be referenced by pointer.
  • TCP_WRITE_FLAG_MORE indicates that the push flag should not be set in the TCP segment.

The tcp_write() function will fail and return ERR_MEM if the length of the data exceeds the current send buffer size or if the length of the queue of outgoing segment is larger than the upper limit defined in lwipopts.h (TCP_SND_QUEUELEN). If the function returns ERR_MEM, the application should wait until some of the currently enqueued data has been successfully received by the other host and try again.

err_t tcp_output(struct tcp_pcb * pcb)

Forces all enqueued data to be sent now.

void tcp_sent(struct tcp_pcb * pcb,
               err_t (* sent)(void * arg, struct tcp_pcb * tpcb,
                              u16_t len))

Specifies the callback function that should be called when data has been acknowledged by the remote host. The len argument passed to the callback function gives the number of bytes that were acknowledged by the last acknowledgment.