lkml.org 
[lkml]   [1996]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subjectipv6 structure alignment?
Date
I have a version of csum_ipv6_magic optimized for the Alpha,
but in implementing it I would prefer struct in6_addr aligned
on a 64-bit boundary.

Can someone tell me which of the structures in the kernel
headers are seen on the wire (and so would care about a
structure size change due to alignment) and which are just
internal?

I looked through the ones in include/linux, figuring that
the ones in include/net would all be internal, and found
that in6_rtmsg and in6_pktinfo would be affected.

Oh, and there is a typo in the generic csum_ipv6_magic.


r~
-------
diff -urNp linux-2.1.8-stock/arch/alpha/lib/csum_ipv6_magic.S linux-2.1.8/arch/alpha/lib/csum_ipv6_magic.S
--- linux-2.1.8-stock/arch/alpha/lib/csum_ipv6_magic.S Wed Dec 31 18:00:00 1969
+++ linux-2.1.8/arch/alpha/lib/csum_ipv6_magic.S Sat Nov 9 17:18:46 1996
@@ -0,0 +1,68 @@
+/*
+ * arch/alpha/lib/csum_ipv6_magic.S
+ * Contributed by Richard Henderson <rth@tamu.edu>
+ *
+ * unsigned short csum_ipv6_magic(struct in6_addr *saddr,
+ * struct in6_addr *daddr,
+ * __u16 len,
+ * unsigned short proto,
+ * unsigned int csum);
+ */
+
+ .globl csum_ipv6_magic
+ .align 4
+ .ent csum_ipv6_magic
+ .frame $30,0,$26,0
+csum_ipv6_magic:
+ .prologue 0
+
+ ldq $0,0($16) # e0 : load src & dst addr words
+ zapnot $20,15,$20 # .. e1 : zero extend incoming csum
+ extwh $18,7,$4 # e0 : byte swap len & proto while we wait
+ ldq $1,8($16) # .. e1 :
+ extbl $18,1,$18 # e0 :
+ ldq $2,0($17) # .. e1 :
+ extwh $19,7,$5 # e0 :
+ ldq $3,8($17) # .. e1 :
+ extbl $19,1,$19 # e0 :
+ or $18,$4,$18 # .. e1 :
+ addq $20,$0,$20 # e0 : begin summing the words
+ or $19,$5,$19 # .. e1 :
+ sll $18,48,$18 # e0 :
+ cmpult $20,$0,$0 # .. e1 :
+ sll $19,48,$19 # e0 :
+ addq $20,$1,$20 # .. e1 :
+ sra $18,32,$18 # e0 : len complete
+ cmpult $20,$1,$1 # .. e1 :
+ sra $19,32,$19 # e0 : proto complete
+ addq $20,$2,$20 # .. e1 :
+ cmpult $20,$2,$2 # e0 :
+ addq $20,$3,$20 # .. e1 :
+ cmpult $20,$3,$3 # e0 :
+ addq $20,$18,$20 # .. e1 :
+ cmpult $20,$18,$18 # e0 :
+ addq $20,$19,$20 # .. e1 :
+ cmpult $20,$19,$19 # e0 :
+ addq $0,$1,$0 # .. e1 : merge the carries back into the csum
+ addq $2,$3,$2 # e0 :
+ addq $18,$19,$18 # .. e1 :
+ addq $0,$2,$0 # e0 :
+ addq $20,$18,$20 # .. e1 :
+ addq $0,$20,$0 # e0 :
+ unop # :
+ extwl $0,2,$2 # e0 : begin folding the 64-bit value
+ zapnot $0,3,$3 # .. e1 :
+ extwl $0,4,$1 # e0 :
+ addq $2,$3,$3 # .. e1 :
+ extwl $0,6,$0 # e0 :
+ addq $3,$1,$3 # .. e1 :
+ addq $0,$3,$0 # e0 :
+ unop # :
+ extwl $0,2,$1 # e0 :
+ zapnot $0,3,$0 # .. e1 :
+ addq $0,$1,$0 # e0 :
+ unop # :
+ not $0,$0 # e0 :
+ ret # .. e1 :
+
+ .end csum_ipv6_magic
diff -urNp linux-2.1.8-stock/include/asm-alpha/checksum.h linux-2.1.8/include/asm-alpha/checksum.h
--- linux-2.1.8-stock/include/asm-alpha/checksum.h Tue Oct 3 05:18:54 1995
+++ linux-2.1.8/include/asm-alpha/checksum.h Sat Nov 9 17:05:53 1996
@@ -66,4 +66,11 @@ static inline unsigned short csum_fold(u
return ~sum;
}

+#define _HAVE_ARCH_IPV6_CSUM
+extern unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
+ struct in6_addr *daddr,
+ __u16 len,
+ unsigned short proto,
+ unsigned int sum);
+
#endif
diff -urNp linux-2.1.8-stock/include/linux/in6.h linux-2.1.8/include/linux/in6.h
--- linux-2.1.8-stock/include/linux/in6.h Sat Nov 9 17:19:52 1996
+++ linux-2.1.8/include/linux/in6.h Sat Nov 9 17:12:45 1996
@@ -27,11 +27,15 @@ struct in6_addr
{
union
{
- unsigned char u6_addr8[16];
+ __u8 u6_addr8[16];
__u32 u6_addr32[4];
+#if (~0UL) > 0xffffffff
+ __u64 u6_addr64[2];
+#endif
} in6_u;
-#define s6_addr32 in6_u.u6_addr32
#define s6_addr in6_u.u6_addr8
+#define s6_addr32 in6_u.u6_addr32
+#define s6_addr64 in6_u.u6_addr64
};

struct sockaddr_in6 {
diff -urNp linux-2.1.8-stock/include/net/checksum.h linux-2.1.8/include/net/checksum.h
--- linux-2.1.8-stock/include/net/checksum.h Sat Nov 9 17:19:52 1996
+++ linux-2.1.8/include/net/checksum.h Sat Nov 9 17:08:18 1996
@@ -81,8 +81,8 @@ static __inline__ unsigned short int csu
csum += carry;

uproto = htonl(proto);
- csum += proto;
- carry = (csum < proto);
+ csum += uproto;
+ carry = (csum < uproto);
csum += carry;

return csum_fold(csum);
\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.044 / U:1.856 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site