lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] Misalignment problems on PowerPC (little endian mode)


From: Muhamad Ikhwan Ismail
Subject: RE: [lwip-users] Misalignment problems on PowerPC (little endian mode)
Date: Tue, 27 May 2008 08:34:14 +0000


Hi,

Changing the headers would require me to change all the header processing routines?
Was the solution meant for me, or rather the lwip project?

Simon, Jonathan or Kieran,
I have encountered alignment errors (after my own fixes) due to out of seq TCP packets. The tcp headers are
stored in the pcb, meaning the seqno field is unaligned everytime it is accessed when I have out of sequence packets,
am I correct?
What happens if I turn off the OOSEQ module ? I assume it would mean all out of sequence packets will be dropped and
will be retransmitted in sequence ?

Thanks a lot in advance,
Ikhwan




> Date: Mon, 26 May 2008 13:59:18 -0300
> From: address@hidden
> To: address@hidden
> Subject: Re: [lwip-users] Misalignment problems on PowerPC (little endian mode)
>
> Hi,
>
> I have seen a tcp sw package somewhere (sory, but I don't remember
> which) that used a good generic approach: headers were stored as char[]
> and macros where available to access fields. I didn't understand at the
> time why use that, but it is easy, fast and *100% PORTABLE*. Letme give
> an example:
>
> struct myStruct{
> short int field1;
> long field2;
> }data;
> x=data->field1; /* using field1 */
>
> would become:
> char data[6];
> #define FIELD1(A) (*((short int*)&A[0]))
> #define FIELD2(A) (*((long*)&A[2]))
> x=FIELD1(data); /* using field1 */
>
> This is feasible for Protocol headers that never change,...
>
> Alain
>
>
> Timmy Brolin escreveu:
> > If your FEC does not allow storing of packets at an 2 byte offset, then
> > you could try setting up the FEC to store the Ethernet header in one
> > small PBUF, and the rest of the packet in a large 1500 byte PBUF. That
> > way your IP headers will be aligned.
> > The downside is of course that for this to work all incomming packets
> > regardless of size will use the full 1500 bytes.
> > You would need to setup every other pbuf in the FEC Rx DMA chain to 14
> > bytes and 1500 bytes respectively.
> > Regards,
> > Timmy Brolin
> >
> > Muhamad Ikhwan Ismail wrote:
> >>
> >> Hi Timmy,
> >>
> >> If you read my prev post, you would know why the padding is useless to
> >> me.
> >>
> >> To Simon,
> >>
> >> Understandable. Well if someone has the same problem, and checks this
> >> thread I guess he can always just bring it back up.
> >> PowerPC is more robust in big endian mode, it even corrects the
> >> misalignment in big endian mode internallly (hardware). Why and how
> >> to be honest I dont know (barely had any training on PowerPC, learned
> >> all through books.)
> >> There are certain PowerPC assembler intructions that cause problems in
> >> little endian mode, I dont remember them by hard, need
> >> to check the book.
> >>
> >> Though you are correct about my method of correcting the problem would
> >> make lwip slower :
> >>
> >> 1. My driver didnt have to copy the received buffer at all. So I spare
> >> a lot there.
> >> 2. Fixing alignment in little endian mode is a very2 long process/routine.
> >> 3. And I dont have to copy the header everytime. E.g in TCP I only had
> >> to copy the header once for the multiple header processing.
> >>
> >> So I hope this brings the end to the thread, at least till someone
> >> might need something out of it. I am thankful that so many people
> >> had tried to help.
> >>
> >> Greetings,
> >> Ikhwan
> >>
> >>
> >>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> > Date: Sat, 24 May 2008 22:28:38 +0200
> >> > From: address@hidden
> >> > To: address@hidden
> >> > Subject: Re: [lwip-users] Misalignment problems on PowerPC (little
> >> endian mode)
> >> >
> >> >
> >> > >> I have the source which can be compiled if the option
> >> > >> LWIP_MISALIGNMENT is set to 1. If anyone interested and have the
> >> same
> >> > >> problem, I am more than willing to share and help. If you guys want
> >> > >> to incorporate it to lwip as alternative solution to structure
> >> > >> packing I am glad I can help. This lowers the stack performance a
> >> bit
> >> > >> though.
> >> > >
> >> > >
> >> > > Not to offend you, but personally, I see this as a bug in the
> >> compiler
> >> > > you are using and we don't support broken compilers: structure
> >> packing
> >> > > _is_ a must for lwIP!
> >> > >
> >> > > Hope you are still having fun with lwIP!
> >> > >
> >> > > Simon
> >> > >
> >> > Actually, no. Structure packing is not necessarily a must for lwip.
> >> > In many cases lwip should work just fine without structure packing. I
> >> > know that Texas Instruments DSP compilers will work with lwip without
> >> > structure packing.
> >> > Patches made to lwip several years ago ensured that if ETH_PAD_SIZE is
> >> > set to 2, then no variable will ever be unaligned. This solves most of
> >> > the problems which would otherwise require structure packing.
> >> >
> >> > There are two things a compiler may do which will still mess up the
> >> lwip
> >> > structs:
> >> > 1: Some compilers pad the size of all structs so that the size of a
> >> > struct becomes a multiple of 4.
> >> > 2: Some comiplers put all structs on an address boundary of 4,
> >> > regardless of the actual boundary requirements of the members of the
> >> struct.
> >> > Compilers which does any of the above would still require packed
> >> > structs. Compilers which does neither of the above should work without
> >> > packed structs, if ETH_PAD_SIZE is set to 2.
> >> >
> >> > Regards,
> >> > Timmy Brolin
> >> >
> >> >
> >> > _______________________________________________
> >> > lwip-users mailing list
> >> > address@hidden
> >> > http://lists.nongnu.org/mailman/listinfo/lwip-users
> >>
> >>
> >> ------------------------------------------------------------------------
> >> Make every e-mail and IM count. Join the i’m Initiative from
> >> Microsoft.
> >> <http://im.live.com/Messenger/IM/Join/Default.aspx?source=EML_WL_%20MakeCount>
> >>
> >> ------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> lwip-users mailing list
> >> address@hidden
> >> http://lists.nongnu.org/mailman/listinfo/lwip-users
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > lwip-users mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/lwip-users
>
>
> _______________________________________________
> lwip-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/lwip-users


Keep your kids safer online with Windows Live Family Safety. Help protect your kids.

reply via email to

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