lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re: [lwip] Re: lwIP on DSPs


From: Adam Dunkels
Subject: [lwip-users] Re: [lwip] Re: lwIP on DSPs
Date: Thu, 09 Jan 2003 00:58:40 -0000

Hi!

On Saturday 01 December 2001 17.05, you wrote:
> From what I found, the port of lwIP to a processor with 16 bits chars
> is a major undertaking.  It will take a very significant rewrite and
> the end result will be a lot different than the original.  If anyone
> plans to go though with it, my suggestion is to abandon efforts make
> the changes using #if's to switch between what is there now and what
> you will need to make it work.  You might use lwIP as a guide for
> what you need but much of it will have to be thrown out and
> re-written for the DSP.

I would be interested in hearing what your study has shown has to be 
rewritten. I haven't looked into the matter, but I would believe that only 
the structs that define protocol headers would be affected by the 16-bit 
u8_t. Also, the checksum calculation would have to be slightly modified. Have 
you found other places as well?

The fix would be a rewrite of the protocol implementations where the currect 
struct-based protocol header scheme would have to be replaced with something 
else. Perhaps by using #defines such as #define TCPH_FLAGS(x) to get the 
actual header fields. Those defines could then be tweaked to suite the 
particular architecture. For instance, on a systems with 16-bit chars, the 
TCP header could be defined as:

struct tcp_hdr {
  u16_t src, dest;
  u32_t seqno, ackno;
/*  u8_t offset; */
/*  u8_t flags; */
  u16_t offset_flags;
  u16_t wnd;
  u16_t chksum;
  u16_t urgp;
}

#define TCPH_SRC(hdr) (hdr)->src
#define TCPH_DEST(hdr) (hdr)->dest
#define TCPH_OFFSET(hdr) (ntohs((hdr)->offset_flags) >> 8)
#define TCPH_FLAGS(hdr) (ntohs((hdr)->offset_flags) & 0xff)
#define /* etc.*/

For a DSP with 32-bit chars, the equivalent (but a lot trickier) struct and 
#defines could be done. This way, the actual protocol code wouldn't have to 
be changed in any way. A single #define in arch/cpu.h or arch/cc.h would 
change they way the protocol headers are defined. 

Leon, your DHCP and ARP code used #defines in this way to extract header 
field values, perhaps you can comment on the above. Does your entire stack 
work this way? Were there any particular reson for doing it that way or for 
doing it the struct way (such as lwIP)?

In any case, this is a good thing to put into lwIP 0.6.

/adam
-- 
Adam Dunkels <address@hidden>
http://www.sics.se/~adam

[This message was sent through the lwip discussion list.]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]