Page 18 of 26 FirstFirst ... 81617181920 ... LastLast
Results 171 to 180 of 254

Thread: Altera TSE driver and example program for lwIP (1.3.2)

  1. #171
    Join Date
    Dec 2008
    Posts
    238
    Rep Power
    1

    Default Re: Altera TSE driver and example program for lwIP (1.3.2)

    There may be a much faster way to handle these 1-3 byte SGDMA transfers.

    I believe it to be true that there would only be one 1-byte pbuf in a chain, is this true? If it *is* true, you could ensure that all pbufs are allocated with an extra 4 bytes of payload. This would be done for PBUF_POOL (not sure about PBUF_RAM). Take the 1 to 3 bytes of the next pbuf and add it to the end of the payload of the preceding one. Increase that len by 1 to 3 and set the second one to 0. Leave the chain in place but skip pbufs with len==0.

    This would be very efficient for the common case of a trailing short pbuf chain.

    For PBUF_REF you may have to unwind to a new pbuf. Or ensure 0-copy doesn't use small payloads (probably not hard to manage).

    Bill

  2. #172
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    1

    Default Re: Altera TSE driver and example program for lwIP (1.3.2)

    I'm new to this tse code and example program but it seems that in the implementation of timers when the variable lwip250mStimer reaches the limit of alt_u32 timers will not work anymore. Am I right ? according to this such program will work for approximately 50days.

    thanks

  3. #173
    Join Date
    Dec 2008
    Posts
    238
    Rep Power
    1

    Default Re: Altera TSE driver and example program for lwIP (1.3.2)

    Good point! Yes, true, about 50 days. The point was to provide a TSE lwIP driver and the application is far from production ready (or production usable in a real application). However, this example isn't correct and it should be. Originally I was going to post only the TSE driver. I thought it would be nice to see it work so threw in main.c - hastily as you pointed out:

    The:
    Code:
    lwip250mStimer += 250;
    Should be:
    Code:
        if( lwip250mStimer >= 0xFFFFFFFF - 249 )
            lwip250mStimer = 0;
        else
            lwip250mStimer += 250;
    Thanks - good find. There is probably a better and/or more efficient way to call lwIP timers. lwIP also now includes timer handling internally so if used would avoid this bug as well. See timers.c/h in lwIP and LWIP_TIMERS in lwipopts.h.

    Bill

  4. #174
    Join Date
    Oct 2011
    Posts
    5
    Rep Power
    1

    Default Re: Altera TSE driver and example program for lwIP (1.3.2)

    Thanks for your reply,

    I have another problem
    When i use a tcp_write() with data which are 535 bytes long i can get to 10Mbit speed on 100Mbit link.
    But when the length of the data is more than 535 bytes performance drops to the speed around 120kbit

    Also 10Mbit speed isn't very much but i assumed that with bigger data chunks the speed will be increased but it isn't true

    Anyway with UDP i can get to 82Mbit on 100Mbit link....

    Any ideas?

    thanks

  5. #175
    Join Date
    Dec 2008
    Posts
    238
    Rep Power
    1

    Default Re: Altera TSE driver and example program for lwIP (1.3.2)

    lwipopts.h is not optimized and close to the shipped opts.h. One set of settings for one person's idea of fast might not be for another's. Or might take up more resources than is available. There are many posts on the lwip forum (at savannah.org) about "optimum" options. On a NIOS II system with gobs of RAM, I hike TCP_WND, and allow 1000's of packet buffers. Also allow more pending packets (MEMP_NUM_TCP_SEG) and use a full MSS. Unfortunately one of the limits in speed is the Altera driver which is partly why Interniche is dead slow (and dies with any kind of packet flood).

    TCP writing is faster than reading. You should get close to 100Mpbs in both directions with "good" lwip options. I use Gig and it's OK on sending but has trouble with high speed receiving - I'm still trying to get a hardware update to get flow control working. My high bandwidth stuff is using UDP and 500Mbps outbound is easily possible. My TCP app with large amounts of inbound TCP isn't so critical but needs to be 40Mbps or so which was not a problem.

    I use RAW API in lwIP and that's a huge speed advantage over netconn or worse, sockets. It all depends on what you need for the API.

    Somewhere I posted the 10 or 12 best things you can do to improve performance. Note that in lwIP 1.4.x a couple of the speed improvements came from patches submitted by me (notable inline IP checksumming). 1.4.x is definitely better than 1.3.x which this example is based on. I recommend using the latest lwIP release.

    Hope this helps,
    Bill

  6. #176
    Join Date
    Nov 2009
    Location
    uk
    Posts
    1,617
    Rep Power
    1

    Default Re: Altera TSE driver and example program for lwIP (1.3.2)

    Timers should normally use 'modulo' arithmetic - where you always subtract the two values that contain 'times' and then look at the value of the difference.
    So if the current time is 'ms_ticks' use:
    Code:
    if ((int)(ms_ticks - lwip250mStimer) >= 0) {
        /* timer has expired */
        lwip250mStimer += 250;
    }
    Rather than checking for ms_ticks >= lwip250mStimer.

  7. #177
    Join Date
    Aug 2010
    Posts
    43
    Rep Power
    1

    Default Re: Altera TSE driver and example program for lwIP (1.3.2)

    Bill,

    Quote Originally Posted by BillA View Post
    If you NAK each packet, yes. And sending is faster. I have a multi-nak protocol which might have to go back in the buffer and resend one or more packets. I actually build and checksum the IP and UDP headers in a static position and only patch the checksum before sending the packet header and payload. This is because most of the header doesn't change. lwIP could incorporate this too because once connected to a PCB, much of the header and that checksum part is static.
    When you receive multi-nak response you may simply build a list of descriptors, pointing to appropriate stored packets, and feed it to SGDMA to retransmit complete batch asynchronously. The overhead is large number of SGDMA descriptors (I used one for every packet in the retransmit buffer) + space for headers + need for dedicated SGDMA hardware. Also I had to design my protocol such that retransmitted packets are exact copies of the originals. I tested this for up to 100% retransmit rate @ 300MBit/sec. Frankly speaking now I switched back to simple udp_send_to_if() because retransmit traffic is miserable on real LAN when appropriate software at host side is used.

    Igor

  8. #178
    Join Date
    Aug 2010
    Posts
    43
    Rep Power
    1

    Default Re: Altera TSE driver and example program for lwIP (1.3.2)

    Bill,

    Quote Originally Posted by BillA View Post
    There may be a much faster way to handle these 1-3 byte SGDMA transfers.

    I believe it to be true that there would only be one 1-byte pbuf in a chain, is this true? If it *is* true, you could ensure that all pbufs are allocated with an extra 4 bytes of payload. This would be done for PBUF_POOL (not sure about PBUF_RAM). Take the 1 to 3 bytes of the next pbuf and add it to the end of the payload of the preceding one. Increase that len by 1 to 3 and set the second one to 0. Leave the chain in place but skip pbufs with len==0.
    This would be very efficient for the common case of a trailing short pbuf chain.
    May be, but not sure. I didn’t analyze TCP code in depth, but it looks like LWIP 1.4.0 tends to combine all writes, even NOCOPY ones, into single oversized buffer. That is why the driver usually sees a single “long” pbuf for single TCP packet. The notable exception I was “lucky” to trap into is a sequence of NOCOPY writes, issued in the moment when internal buffer is empty. In this state TCP allocates separate pbuf for the headers and chain it with the PBUF_REFs, pointing to user supplied data.
    Quote Originally Posted by BillA View Post
    For PBUF_REF you may have to unwind to a new pbuf. Or ensure 0-copy doesn't use small payloads (probably not hard to manage).
    Surely this could be easily managed when one builds application from ground. But could be rather confusing when such things happen deep inside third-party code e.g. http server.

    Igor

  9. #179
    Join Date
    Aug 2010
    Posts
    43
    Rep Power
    1

    Default Re: Altera TSE driver and example program for lwIP (1.3.2)

    PETRAK,
    Quote Originally Posted by PETRAK View Post
    I'm new to this tse code and example program but it seems that in the implementation of timers when the variable lwip250mStimer reaches the limit of alt_u32 timers will not work anymore. Am I right ? according to this such program will work for approximately 50days.
    I would add to Bill’s comment that the timer code in the example is error prone. If any of XXX_TMR_INTERVAL constants happens to be not divisible by 250, you will get incorrect period LCM(XXX_TMR_INTERVAL, 250) for that timer. For example, if you simply enable AUTO_IP in your lwipopts.h, you will have 500ms period for autoip_tmr() instead of intended 100ms.

    Dsl, The problem is not the wrapping itself, but that 2^32 is not divisible by 250.

    Igor

  10. #180
    Join Date
    Nov 2009
    Location
    uk
    Posts
    1,617
    Rep Power
    1

    Default Re: Altera TSE driver and example program for lwIP (1.3.2)

    If you use modulo arithmetic, it doesn't matter whether the timeout divides into 2^32.
    If you try not to use modulo arithmetic you have real trouble expiring certain timers - eg 257 ticks.

Similar Threads

  1. LWIP & NIOS : driver for Altera TSE (triple speed ethernet mac)
    By dvb_man in forum General Software Forum
    Replies: 3
    Last Post: June 21st, 2010, 05:41 AM
  2. Altera TSE driver for lwip
    By joymcjoy in forum IP Discussion
    Replies: 4
    Last Post: June 21st, 2010, 05:40 AM
  3. TSE MAC driver reconnect issue
    By cellis5902 in forum IP Discussion
    Replies: 0
    Last Post: May 19th, 2009, 07:43 AM
  4. Lan91c111 driver without LWIP
    By heavenscape in forum General Discussion Forum
    Replies: 4
    Last Post: March 6th, 2007, 03:40 AM
  5. I got a problem when write a ap program with lwip
    By bearmowmow in forum General Software Forum
    Replies: 0
    Last Post: September 25th, 2005, 02:04 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •