From: Pravin B Shelar Date: Fri, 30 Aug 2013 17:42:53 +0000 (-0700) Subject: datapath: Remove reciprocal_div compat code. X-Git-Tag: v2.0~68 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=16fccf12ec91808f086d2299c42e36aa3c19447a datapath: Remove reciprocal_div compat code. Signed-off-by: Pravin B Shelar Acked-by: Jesse Gross --- diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk index 085e8fdd9..92cd52068 100644 --- a/datapath/linux/Modules.mk +++ b/datapath/linux/Modules.mk @@ -56,7 +56,6 @@ openvswitch_headers += \ linux/compat/include/linux/poison.h \ linux/compat/include/linux/rculist.h \ linux/compat/include/linux/rcupdate.h \ - linux/compat/include/linux/reciprocal_div.h \ linux/compat/include/linux/rtnetlink.h \ linux/compat/include/linux/sctp.h \ linux/compat/include/linux/skbuff.h \ diff --git a/datapath/linux/compat/include/linux/reciprocal_div.h b/datapath/linux/compat/include/linux/reciprocal_div.h deleted file mode 100644 index f618bddc6..000000000 --- a/datapath/linux/compat/include/linux/reciprocal_div.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __LINUX_RECIPROCAL_DIV_WRAPPER_H -#define __LINUX_RECIPROCAL_DIV_WRAPPER_H - -#include - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20) -#include_next -#else - -#include - -/* - * This file describes reciprocical division. - * - * This optimizes the (A/B) problem, when A and B are two u32 - * and B is a known value (but not known at compile time) - * - * The math principle used is : - * Let RECIPROCAL_VALUE(B) be (((1LL << 32) + (B - 1))/ B) - * Then A / B = (u32)(((u64)(A) * (R)) >> 32) - * - * This replaces a divide by a multiply (and a shift), and - * is generally less expensive in CPU cycles. - */ - -/* - * Computes the reciprocal value (R) for the value B of the divisor. - * Should not be called before each reciprocal_divide(), - * or else the performance is slower than a normal divide. - */ -extern u32 reciprocal_value(u32 B); - - -static inline u32 reciprocal_divide(u32 A, u32 R) -{ - return (u32)(((u64)A * R) >> 32); -} - -#endif /* Linux kernel < 2.6.20 */ -#endif /* __LINUX_RECIPROCAL_DIV_WRAPPER_H */ diff --git a/datapath/linux/compat/reciprocal_div.c b/datapath/linux/compat/reciprocal_div.c index 6a3bd48fa..7ec752840 100644 --- a/datapath/linux/compat/reciprocal_div.c +++ b/datapath/linux/compat/reciprocal_div.c @@ -1,9 +1,13 @@ #include #include +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) +/* definition is required since reciprocal_value() is not exported */ u32 reciprocal_value(u32 k) { u64 val = (1LL << 32) + (k - 1); do_div(val, k); return (u32)val; } +#endif