On Monday 11 December 2006 2:48 am, Nikita V. Youshchenko wrote:
> 
> > On Sunday 10 December 2006 1:58 pm, Nikita V. Youshchenko wrote:
> > > +static inline void ensure_alignment(struct sk_buff *skb)
> > > +{
> > > +       char *pkt = skb->data;
> > > +       int offset = NET_IP_ALIGN ? ((unsigned long)pkt - NET_IP_ALIGN) & 
> > > 3 : 0;
> >
> > I suppose it's reasonable to expect that at most the low 2 bits must
> > be zero (i.e. align to max of u32), but it just _looks_ wrong ...
> 
> Can't understand what do you mean by "at most the low 2 bits must be zero",
> sorry. Could you please explain?

You're masking with magic number 0x03, which assumes that only the low 2 bits
a must be zero.  Oh, and if it's _already_ aligned you're still moving it...

The "reasonable" is just that I think the network stack uses u32 all over
the place, and not u64, so it's probably safe to assume NET_IP_ALIGN isn't
going to demand e.g. 8 byte alignment.


> I assume that required alignment of frame beginning is (4n + NET_IP_ALIGN) -

I don't know where that "4n" comes from; if N = 2 you're saying ten byte
alignment in the typical case, and that doesn't match anything I ever
heard of.  On any platform or OS.


> And there is at least 4 bytes available before pkt (that was used for
> frame size word in urb space).

Then it's worth a comment highlighting that fact.  In the context of
that function, it's not clear.




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to