Skip to contentSkip to conversation

m68k: merge the mmu and non-mmu versions of checksum.h

PATCH In review Greg Ungerer 2 participants 3 messages Jun 17, 2009 – Jun 19, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 m68k: merge the mmu and non-mmu versions of checksum.h

[PATCH] m68k: merge the mmu and non-mmu versions of checksum.h

There is only minimal difference between the mmu and non-mmu versions of checksum.h. Most of its contents is shared. Merge the two separate files back into a single checksum.h.

---
 .../m68k/include/asm/{checksum_mm.h => checksum.h} |   11 ++
 arch/m68k/include/asm/checksum_no.h                |  132 --------------------
 arch/m68knommu/lib/checksum.c                      |    9 --
 3 files changed, 11 insertions(+), 141 deletions(-)
 rename arch/m68k/include/asm/{checksum_mm.h => checksum.h} (93%)
 delete mode 100644 arch/m68k/include/asm/checksum_no.h
arch/m68k/include/asm/checksum.h renamed from arch/m68k/include/asm/checksum_mm.h +11 -0
similarity index 93%
rename from arch/m68k/include/asm/checksum_mm.h
rename to arch/m68k/include/asm/checksum.h
index 494f9ae..87cabc3 100644
@@ -34,6 +34,8 @@ extern __wsum csum_partial_copy_nocheck(const void *src,
 					      void *dst, int len,
 					      __wsum sum);
 
+
+#ifdef CONFIG_MMU
 /*
  *	This is a version of ip_compute_csum() optimized for IP headers,
  *	which always checksum on 4 octet boundaries.
@@ -59,6 +61,9 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
 		 : "memory");
 	return (__force __sum16)~sum;
 }
+#else
+__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
+#endif
 
 /*
  *	Fold a partial checksum
@@ -67,6 +72,11 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
 static inline __sum16 csum_fold(__wsum sum)
 {
 	unsigned int tmp = (__force u32)sum;
+#ifdef CONFIG_COLDFIRE
+	tmp = (tmp & 0xffff) + (tmp >> 16);
+	tmp = (tmp & 0xffff) + (tmp >> 16);
+	return (__force __sum16)~tmp;
+#else
 	__asm__("swap %1\n\t"
 		"addw %1, %0\n\t"
 		"clrw %1\n\t"
@@ -74,6 +84,7 @@ static inline __sum16 csum_fold(__wsum sum)
 		: "=&d" (sum), "=&d" (tmp)
 		: "0" (sum), "1" (tmp));
 	return (__force __sum16)~sum;
+#endif
 }
 
 
arch/m68k/include/asm/checksum_no.h deleted +0 -132

132 lines not on this page · raw message

arch/m68knommu/lib/checksum.c +0 -9
index 269d83b..8bf012a 100644
@@ -127,15 +127,6 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
 EXPORT_SYMBOL(csum_partial);
 
 /*
- * this routine is used for miscellaneous IP-like checksums, mainly
- * in icmp.c
- */
-__sum16 ip_compute_csum(const void *buff, int len)
-{
-	return (__force __sum16)~do_csum(buff,len);
-}
-
-/*
  * copy from fs while checksumming, otherwise like csum_partial
  */
 
#1 lore raw

arch/m68k/include/asm/checksum.h static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) · line 66

Quoted 11 lines · Greg Ungerer
arch/m68k/include/asm/checksum.h renamed from arch/m68k/include/asm/checksum_mm.h +4 -0
+#ifdef CONFIG_MMU
 /*
  *	This is a version of ip_compute_csum() optimized for IP headers,
  *	which always checksum on 4 octet boundaries.
@@ -59,6 +61,9 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
 		 : "memory");
 	return (__force __sum16)~sum;
 }
+#else
+__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
+#endif

Any good reason this is inline for all mmu processors and out of line for nommu, independent of the actual cpu variant?

Quoted 12 lines
arch/m68k/include/asm/checksum.h renamed from arch/m68k/include/asm/checksum_mm.h +5 -0
 static inline __sum16 csum_fold(__wsum sum)
 {
 	unsigned int tmp = (__force u32)sum;
+#ifdef CONFIG_COLDFIRE
+	tmp = (tmp & 0xffff) + (tmp >> 16);
+	tmp = (tmp & 0xffff) + (tmp >> 16);
+	return (__force __sum16)~tmp;
+#else
 	__asm__("swap %1\n\t"
 		"addw %1, %0\n\t"
 		"clrw %1\n\t"

arch/m68k/include/asm/checksum.h static inline __sum16 csum_fold(__wsum sum) · line 88

Quoted 5 lines
arch/m68k/include/asm/checksum.h renamed from arch/m68k/include/asm/checksum_mm.h +1 -0
@@ -74,6 +84,7 @@ static inline __sum16 csum_fold(__wsum sum)
 		: "=&d" (sum), "=&d" (tmp)
 		: "0" (sum), "1" (tmp));
 	return (__force __sum16)~sum;
+#endif
 }

I think this would be cleaner by having totally separate functions for both cases, e.g.

#ifdef CONFIG_COLDFIRE
static inline __sum16 csum_fold(__wsum sum)

{
	unsigned int tmp = (__force u32)sum;

	tmp = (tmp & 0xffff) + (tmp >> 16);
	tmp = (tmp & 0xffff) + (tmp >> 16);

	return (__force __sum16)~tmp;
}

#else
...
#endif

#2 lore raw

Hi Christoph,

Quoted 15 lines · Christoph Hellwig

arch/m68k/include/asm/checksum.h static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) · line 66

Quoted 11 lines · Greg Ungerer
arch/m68k/include/asm/checksum.h renamed from arch/m68k/include/asm/checksum_mm.h +4 -0
+#ifdef CONFIG_MMU
 /*
  *	This is a version of ip_compute_csum() optimized for IP headers,
  *	which always checksum on 4 octet boundaries.
@@ -59,6 +61,9 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
 		 : "memory");
 	return (__force __sum16)~sum;
 }
+#else
+__sum16 ip_fast_csum(const void *iph, unsigned int ihl);
+#endif

Any good reason this is inline for all mmu processors and out of line for nommu, independent of the actual cpu variant?

I don't recall of the simple (and thus non-mmu) m68k variants support all the instructions used in this optimized version. I will check that. It might be that this is mis-placed and is actually conditional on the CPU type.

The C code version is significantly bigger, I think that is why it was not inlined here (see arch/m68knommu/lib/checksum.c)

Quoted 31 lines
Quoted 12 lines
arch/m68k/include/asm/checksum.h renamed from arch/m68k/include/asm/checksum_mm.h +5 -0
 static inline __sum16 csum_fold(__wsum sum)
 {
 	unsigned int tmp = (__force u32)sum;
+#ifdef CONFIG_COLDFIRE
+	tmp = (tmp & 0xffff) + (tmp >> 16);
+	tmp = (tmp & 0xffff) + (tmp >> 16);
+	return (__force __sum16)~tmp;
+#else
 	__asm__("swap %1\n\t"
 		"addw %1, %0\n\t"
 		"clrw %1\n\t"

arch/m68k/include/asm/checksum.h static inline __sum16 csum_fold(__wsum sum) · line 88

Quoted 5 lines
arch/m68k/include/asm/checksum.h renamed from arch/m68k/include/asm/checksum_mm.h +1 -0
@@ -74,6 +84,7 @@ static inline __sum16 csum_fold(__wsum sum)
 		: "=&d" (sum), "=&d" (tmp)
 		: "0" (sum), "1" (tmp));
 	return (__force __sum16)~sum;
+#endif
 }

I think this would be cleaner by having totally separate functions for both cases, e.g.

#ifdef CONFIG_COLDFIRE
static inline __sum16 csum_fold(__wsum sum)

{
	unsigned int tmp = (__force u32)sum;

	tmp = (tmp & 0xffff) + (tmp >> 16);
	tmp = (tmp & 0xffff) + (tmp >> 16);

	return (__force __sum16)~tmp;
}
Quoted 3 lines

#else
...
#endif

Ok, I will change that.

Thanks
Greg

------------------------------------------------------------------------

Greg Ungerer  --  Principal Engineer        EMAIL:     [email protected]
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com