From 9abe56c1bd2becca96d866962d8430ec38a1a412 Mon Sep 17 00:00:00 2001 From: Vladimir Sokolovsky Date: Tue, 26 Nov 2013 17:26:07 +0200 Subject: [PATCH] compat: Added symbols required for SLES11 SP3 support Signed-off-by: Vladimir Sokolovsky --- compat/Makefile | 1 + compat/compat-3.9.c | 89 ++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.h | 2 + include/linux/compat-3.8.h | 12 +++++ include/linux/compat-3.9.h | 12 +++++ include/linux/cpu_rmap.h | 10 +++++ include/linux/llist.h | 13 +++--- 7 files changed, 134 insertions(+), 5 deletions(-) create mode 100644 compat/compat-3.9.c create mode 100644 include/linux/compat-3.8.h create mode 100644 include/linux/compat-3.9.h create mode 100644 include/linux/cpu_rmap.h diff --git a/compat/Makefile b/compat/Makefile index bf7955f..a68f966 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -43,6 +43,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o compat-$(CONFIG_COMPAT_KERNEL_3_5) += compat-3.5.o compat-$(CONFIG_COMPAT_KERNEL_3_6) += compat-3.6.o compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o +compat-$(CONFIG_COMPAT_KERNEL_3_9) += compat-3.9.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.9.c b/compat/compat-3.9.c new file mode 100644 index 0000000..9a06cd5 --- /dev/null +++ b/compat/compat-3.9.c @@ -0,0 +1,89 @@ +/* + * Copyright 2013 Mellanox Technologies Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Compatibility file for Linux RDMA for kernels 3.9. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static u32 hashrnd __read_mostly; + +#define get_xps_queue LINUX_BACKPORT(get_xps_queue) +static inline int get_xps_queue(struct net_device *dev, struct sk_buff *skb) +{ +#ifdef CONFIG_XPS + struct xps_dev_maps *dev_maps; + struct xps_map *map; + int queue_index = -1; + + rcu_read_lock(); + dev_maps = rcu_dereference(dev->xps_maps); + if (dev_maps) { + map = rcu_dereference( + dev_maps->cpu_map[raw_smp_processor_id()]); + if (map) { + if (map->len == 1) + queue_index = map->queues[0]; + else { + u32 hash; + if (skb->sk && skb->sk->sk_hash) + hash = skb->sk->sk_hash; + else + hash = (__force u16) skb->protocol ^ + skb->rxhash; + hash = jhash_1word(hash, hashrnd); + queue_index = map->queues[ + ((u64)hash * map->len) >> 32]; + } + if (unlikely(queue_index >= dev->real_num_tx_queues)) + queue_index = -1; + } + } + rcu_read_unlock(); + + return queue_index; +#else + return -1; +#endif +} + +#define __netdev_pick_tx LINUX_BACKPORT(__netdev_pick_tx) +u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb) +{ + struct sock *sk = skb->sk; + int queue_index = sk_tx_queue_get(sk); + + if (queue_index < 0 || skb->ooo_okay || + queue_index >= dev->real_num_tx_queues) { + int new_index = get_xps_queue(dev, skb); + if (new_index < 0) + new_index = skb_tx_hash(dev, skb); + + if (queue_index != new_index && sk && + rcu_access_pointer(sk->sk_dst_cache)) + sk_tx_queue_set(sk, new_index); + + queue_index = new_index; + } + + return queue_index; +} +EXPORT_SYMBOL(__netdev_pick_tx); diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 3dc3674..af5700e 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -71,6 +71,8 @@ void backport_dependency_symbol(void); #include #include #include +#include +#include #include #include #include diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h new file mode 100644 index 0000000..3c01aeb --- /dev/null +++ b/include/linux/compat-3.8.h @@ -0,0 +1,12 @@ +#ifndef LINUX_3_8_COMPAT_H +#define LINUX_3_8_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) + +#define FLOW_MAC_EXT 0x40000000 + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) */ + +#endif /* LINUX_3_8_COMPAT_H */ diff --git a/include/linux/compat-3.9.h b/include/linux/compat-3.9.h new file mode 100644 index 0000000..b9a45d4 --- /dev/null +++ b/include/linux/compat-3.9.h @@ -0,0 +1,12 @@ +#ifndef LINUX_3_9_COMPAT_H +#define LINUX_3_9_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) + +extern u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */ + +#endif /* LINUX_3_9_COMPAT_H */ diff --git a/include/linux/cpu_rmap.h b/include/linux/cpu_rmap.h new file mode 100644 index 0000000..004416b --- /dev/null +++ b/include/linux/cpu_rmap.h @@ -0,0 +1,10 @@ +#ifndef _COMPAT_LINUX_CPU_RMAP_H +#define _COMPAT_LINUX_CPU_RMAP_H 1 + +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) || defined (CONFIG_COMPAT_IS_LINUX_CPU_RMAP) +#include_next +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)) */ + +#endif /* _COMPAT_LINUX_CPU_RMAP_H */ diff --git a/include/linux/llist.h b/include/linux/llist.h index 08638dc..9206ef5 100644 --- a/include/linux/llist.h +++ b/include/linux/llist.h @@ -2,7 +2,9 @@ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) #include_next -#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) +#else + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) || (defined(CONFIG_SUSE_KERNEL) && defined(CONFIG_COMPAT_SLES_11_2)) #include_next #define llist_add_batch LINUX_BACKPORT(llist_add_batch) extern bool llist_add_batch(struct llist_node *new_first, @@ -10,10 +12,7 @@ extern bool llist_add_batch(struct llist_node *new_first, struct llist_head *head); #define llist_del_first LINUX_BACKPORT(llist_del_first) extern struct llist_node *llist_del_first(struct llist_head *head); -#else -#if (defined(CONFIG_COMPAT_SLES_11_2) || defined(CONFIG_COMPAT_SLES_11_3)) -#include_next #else #ifndef LLIST_H @@ -85,8 +84,12 @@ struct llist_node { struct llist_node *next; }; +#ifndef LLIST_HEAD_INIT #define LLIST_HEAD_INIT(name) { NULL } +#endif +#ifndef LLIST_HEAD #define LLIST_HEAD(name) struct llist_head name = LLIST_HEAD_INIT(name) +#endif /** * init_llist_head - initialize lock-less list head @@ -216,6 +219,6 @@ extern bool llist_add_batch(struct llist_node *new_first, #define llist_del_first LINUX_BACKPORT(llist_del_first) extern struct llist_node *llist_del_first(struct llist_head *head); -#endif /* (defined(CONFIG_COMPAT_SLES_11_2) || defined(CONFIG_COMPAT_SLES_11_3)) */ +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) || (defined(CONFIG_SUSE_KERNEL) && defined(CONFIG_COMPAT_SLES_11_2)) */ #endif /* LLIST_H */ #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) */ -- 2.41.0