From: Vladimir Sokolovsky Date: Mon, 16 Jan 2017 08:23:19 +0000 (+0200) Subject: compat: Added headers and macros to support RHEL7.0 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=77acf49ba2e12b2d88903453edc9b7d6bbc3e4e6;p=~aditr%2Fcompat.git compat: Added headers and macros to support RHEL7.0 Signed-off-by: Vladimir Sokolovsky --- diff --git a/config/rdma.m4 b/config/rdma.m4 index 0b2e7bf..a1db9ba 100644 --- a/config/rdma.m4 +++ b/config/rdma.m4 @@ -398,6 +398,23 @@ AC_DEFUN([LINUX_CONFIG_COMPAT], AC_MSG_RESULT(no) ]) + AC_MSG_CHECKING([if netdev_extended has dev_port]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + struct net_device *dev = NULL; + + netdev_extended(dev)->dev_port = 0; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NETDEV_EXTENDED_DEV_PORT, 1, + [ is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + AC_MSG_CHECKING([if struct ptp_clock_info has n_pins]) LB_LINUX_TRY_COMPILE([ #include @@ -3949,6 +3966,91 @@ AC_DEFUN([LINUX_CONFIG_COMPAT], AC_MSG_RESULT(no) ]) + AC_MSG_CHECKING([if netlink.h has netlink_capable]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + bool b = netlink_capable(NULL, 0); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NETLINK_CAPABLE, 1, + [netlink_capable is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if netlink.h netlink_skb_parms has sk]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + struct netlink_skb_parms nsp = { + .sk = NULL, + }; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NETLINK_SKB_PARMS_SK, 1, + [netlink_skb_params has sk]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if etherdevice.h has ether_addr_copy]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + ether_addr_copy(NULL, NULL); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_ETHER_ADDR_COPY, 1, + [ether_addr_copy is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if struct dcbnl_rtnl_ops has get/set ets and dcbnl defined]) + LB_LINUX_TRY_COMPILE([ + #include + #include + ],[ + const struct dcbnl_rtnl_ops en_dcbnl_ops = { + .ieee_getets = NULL, + .ieee_setets = NULL, + }; + + struct net_device dev = { + .dcbnl_ops = NULL, + }; + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_IEEE_DCBNL_ETS, 1, + [ieee_getets/ieee_setets is defined and dcbnl defined]) + ],[ + AC_MSG_RESULT(no) + ]) + + AC_MSG_CHECKING([if kernel.h has reciprocal_scale]) + LB_LINUX_TRY_COMPILE([ + #include + ],[ + reciprocal_scale(0, 0); + + return 0; + ],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_RECIPROCAL_SCALE, 1, + [reciprocal_scale is defined]) + ],[ + AC_MSG_RESULT(no) + ]) + ]) # # COMPAT_CONFIG_HEADERS diff --git a/include/linux/bitops.h b/include/linux/bitops.h new file mode 100644 index 0000000..0796503 --- /dev/null +++ b/include/linux/bitops.h @@ -0,0 +1,13 @@ +#ifndef COMPAT_BIT_OPS_H +#define COMPAT_BIT_OPS_H + +#include_next + +/* Include the autogenerated header file */ +#include "../../compat/config.h" + +#ifndef BIT_ULL +#define BIT_ULL(nr) (1ULL << (nr)) +#endif + +#endif /* COMPAT_BIT_OPS_H */ diff --git a/include/linux/compat-3.11.h b/include/linux/compat-3.11.h index 18e3247..193fa3e 100644 --- a/include/linux/compat-3.11.h +++ b/include/linux/compat-3.11.h @@ -27,5 +27,21 @@ enum { }; #endif +#include + +#define sg_copy_from_buffer LINUX_BACKPORT(sg_copy_from_buffer) +size_t sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents, + void *buf, size_t buflen); +#define sg_copy_to_buffer LINUX_BACKPORT(sg_copy_to_buffer) +size_t sg_copy_to_buffer(struct scatterlist *sgl, unsigned int nents, + void *buf, size_t buflen); + +#define sg_pcopy_from_buffer LINUX_BACKPORT(sg_pcopy_from_buffer) +size_t sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents, + void *buf, size_t buflen, off_t skip); +#define sg_pcopy_to_buffer LINUX_BACKPORT(sg_pcopy_to_buffer) +size_t sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents, + void *buf, size_t buflen, off_t skip); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)) */ #endif /* LINUX_3_11_COMPAT_H */ diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h new file mode 100644 index 0000000..f9d846d --- /dev/null +++ b/include/linux/etherdevice.h @@ -0,0 +1,32 @@ +#ifndef LINUX_ETHERDEVICE_H +#define LINUX_ETHERDEVICE_H + +#include "../../compat/config.h" + +#include_next + +#ifndef HAVE_ETHER_ADDR_COPY +/** + * ether_addr_copy - Copy an Ethernet address + * @dst: Pointer to a six-byte array Ethernet address destination + * @src: Pointer to a six-byte array Ethernet address source + * + * Please note: dst & src must both be aligned to u16. + */ +static inline void ether_addr_copy(u8 *dst, const u8 *src) +{ +#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) + *(u32 *)dst = *(const u32 *)src; + *(u16 *)(dst + 4) = *(const u16 *)(src + 4); +#else + u16 *a = (u16 *)dst; + const u16 *b = (const u16 *)src; + + a[0] = b[0]; + a[1] = b[1]; + a[2] = b[2]; +#endif +} +#endif /* HAVE_ETHER_ADDR_COPY*/ + +#endif /* LINUX_ETHERDEVICE_H */ diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h index cff23a8..98f0e60 100644 --- a/include/linux/ethtool.h +++ b/include/linux/ethtool.h @@ -12,4 +12,73 @@ #define ETH_MODULE_SFF_8436 0x4 #define ETH_MODULE_SFF_8436_LEN 256 #endif + +#ifndef SPEED_20000 +#define SPEED_20000 20000 +#define SUPPORTED_20000baseMLD2_Full (1 << 21) +#define SUPPORTED_20000baseKR2_Full (1 << 22) +#define ADVERTISED_20000baseMLD2_Full (1 << 21) +#define ADVERTISED_20000baseKR2_Full (1 << 22) +#endif + +#ifndef SPEED_40000 +#define SPEED_40000 40000 +#endif + +#ifndef SPEED_56000 +#define SPEED_56000 56000 +#define SUPPORTED_56000baseKR4_Full (1 << 27) +#define SUPPORTED_56000baseCR4_Full (1 << 28) +#define SUPPORTED_56000baseSR4_Full (1 << 29) +#define SUPPORTED_56000baseLR4_Full (1 << 30) +#define ADVERTISED_56000baseKR4_Full (1 << 27) +#define ADVERTISED_56000baseCR4_Full (1 << 28) +#define ADVERTISED_56000baseSR4_Full (1 << 29) +#define ADVERTISED_56000baseLR4_Full (1 << 30) +#endif + +#define SPEED_25000 25000 +#define SPEED_50000 50000 +#define SPEED_100000 100000 +/*TODO Ethtool new SPEED API */ +#define SUPPORTED_100000baseCR4_Full 0 +#define ADVERTISED_100000baseCR4_Full 0 +#define SUPPORTED_100000baseSR4_Full 0 +#define ADVERTISED_100000baseSR4_Full 0 +#define SUPPORTED_100000baseKR4_Full 0 +#define ADVERTISED_100000baseKR4_Full 0 +#define SUPPORTED_1000000baseLR4_Full 0 +#define ADVERTISED_1000000baseLR4_Full 0 +#define SUPPORTED_100baseTX_Full 0 +#define ADVERTISED_100baseTX_Full 0 +#define SUPPORTED_25000baseCR_Full 0 +#define ADVERTISED_25000baseCR_Full 0 +#define SUPPORTED_25000baseKR_Full 0 +#define ADVERTISED_25000baseKR_Full 0 +#define SUPPORTED_25000baseSR_Full 0 +#define ADVERTISED_25000baseSR_Full 0 +#define SUPPORTED_50000baseCR2_Full 0 +#define ADVERTISED_50000baseCR2_Full 0 +#define SUPPORTED_50000baseKR2_Full 0 +#define ADVERTISED_50000baseKR2_Full 0 + +#ifndef SPEED_UNKNOWN +#define SPEED_UNKNOWN -1 +#endif + +#ifndef DUPLEX_UNKNOWN +#define DUPLEX_UNKNOWN -1 +#endif + +#ifndef SUPPORTED_40000baseKR4_Full +/* Add missing defines for supported and advertised speed features */ +#define SUPPORTED_40000baseKR4_Full (1 << 23) +#define SUPPORTED_40000baseCR4_Full (1 << 24) +#define SUPPORTED_40000baseSR4_Full (1 << 25) +#define SUPPORTED_40000baseLR4_Full (1 << 26) +#define ADVERTISED_40000baseKR4_Full (1 << 23) +#define ADVERTISED_40000baseCR4_Full (1 << 24) +#define ADVERTISED_40000baseSR4_Full (1 << 25) +#define ADVERTISED_40000baseLR4_Full (1 << 26) +#endif #endif diff --git a/include/linux/kernel.h b/include/linux/kernel.h new file mode 100644 index 0000000..46e6a0b --- /dev/null +++ b/include/linux/kernel.h @@ -0,0 +1,38 @@ +#ifndef COMPAT_KERNEL_H +#define COMPAT_KERNEL_H + +#include "../../compat/config.h" + +#include_next + +#ifndef DIV_ROUND_UP_ULL +#define DIV_ROUND_UP_ULL(ll,d) \ + ({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; }) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#ifndef U16_MAX +#define U16_MAX ((u16)~0U) +#endif + +#ifndef U32_MAX +#define U32_MAX ((u32)~0U) +#endif + +#ifndef U64_MAX +#define U64_MAX ((u64)~0U) +#endif + +#ifdef __KERNEL__ +#ifndef HAVE_RECIPROCAL_SCALE +static inline u32 reciprocal_scale(u32 val, u32 ep_ro) +{ + return (u32)(((u64) val * ep_ro) >> 32); +} +#endif +#endif /* __KERNEL__ */ + +#endif /* COMPAT_KERNEL_H */