compat: Compat file changes for rhel and sles origin/HEAD origin/ofed
authorPotnuri Bharat Teja <bharat@chelsio.com>
Tue, 14 Feb 2017 14:46:44 +0000 (20:16 +0530)
committerSteve Wise <swise@opengridcomputing.com>
Fri, 17 Feb 2017 16:51:59 +0000 (08:51 -0800)
Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
Signed-off-by: Steve Wise <swise@opengridcomputing.com>
compat/compat-3.15.c
compat/compat-3.16.c
include/linux/compat-3.15.h
include/linux/compat-3.16.h
include/linux/compat-4.1.h

index a39c2a5..511b71e 100644 (file)
@@ -10,3 +10,15 @@ void kvfree(const void *addr)
                kfree(addr);
 }
 EXPORT_SYMBOL(kvfree);
+
+#define idr_is_empty LINUX_BACKPORT(idr_is_empty)
+static int idr_has_entry(int id, void *p, void *data)
+{
+        return 1;
+}
+
+bool idr_is_empty(struct idr *idp)
+{
+        return !idr_for_each(idp, idr_has_entry, NULL);
+}
+EXPORT_SYMBOL(idr_is_empty);
index b57c041..c30e064 100644 (file)
@@ -68,3 +68,80 @@ out:
        return ret;
 }
 EXPORT_SYMBOL(cpumask_set_cpu_local_first);
+
+static int __hw_addr_del_entry(struct netdev_hw_addr_list *list,
+                               struct netdev_hw_addr *ha, bool global,
+                               bool sync)
+{
+        if (global && !ha->global_use)
+                return -ENOENT;
+
+        if (sync && !ha->synced)
+                return -ENOENT;
+
+        if (global)
+                ha->global_use = false;
+
+        if (sync)
+                ha->synced--;
+
+        if (--ha->refcount)
+                return 0;
+        list_del_rcu(&ha->list);
+        kfree_rcu(ha, rcu_head);
+        list->count--;
+        return 0;
+}
+
+/**
+ *  __hw_addr_sync_dev - Synchonize device's multicast list
+ *  @list: address list to syncronize
+ *  @dev:  device to sync
+ *  @sync: function to call if address should be added
+ *  @unsync: function to call if address should be removed
+ *
+ *  This funciton is intended to be called from the ndo_set_rx_mode
+ *  function of devices that require explicit address add/remove
+ *  notifications.  The unsync function may be NULL in which case
+ *  the addresses requiring removal will simply be removed without
+ *  any notification to the device.
+ **/
+#define __hw_addr_sync_dev LINUX_BACKPORT(__hw_addr_sync_dev)
+int __hw_addr_sync_dev(struct netdev_hw_addr_list *list,
+                       struct net_device *dev,
+                       int (*sync)(struct net_device *, const unsigned char *),
+                       int (*unsync)(struct net_device *,
+                                     const unsigned char *))
+{
+        struct netdev_hw_addr *ha, *tmp;
+        int err;
+
+        /* first go through and flush out any stale entries */
+        list_for_each_entry_safe(ha, tmp, &list->list, list) {
+                if (!ha->sync_cnt || ha->refcount != 1)
+                        continue;
+
+                /* if unsync is defined and fails defer unsyncing address */
+                if (unsync && unsync(dev, ha->addr))
+                        continue;
+
+                ha->sync_cnt--;
+                __hw_addr_del_entry(list, ha, false, false);
+        }
+
+        /* go through and sync new entries to the list */
+        list_for_each_entry_safe(ha, tmp, &list->list, list) {
+                if (ha->sync_cnt)
+                        continue;
+
+                err = sync(dev, ha->addr);
+                if (err)
+                        return err;
+
+                ha->sync_cnt++;
+                ha->refcount++;
+        }
+
+        return 0;
+}
+EXPORT_SYMBOL(__hw_addr_sync_dev);
index bb7ec03..5773b5e 100644 (file)
@@ -2,12 +2,18 @@
 #define LINUX_3_15_COMPAT_H
 
 #include <linux/version.h>
+#include <linux/idr.h>
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0))
 
 #define kvfree LINUX_BACKPORT(kvfree)
 extern void kvfree(const void *addr);
 
+#ifndef HAVE_IDR_IS_EMPTY
+#define idr_is_empty LINUX_BACKPORT(idr_is_empty)
+bool idr_is_empty(struct idr *idp);
+#endif
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)) */
 
 #endif /* LINUX_3_15_COMPAT_H */
index 3cca60a..06c7283 100644 (file)
@@ -42,6 +42,56 @@ int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp);
 #define NETIF_F_GSO_UDP_TUNNEL_CSUM 0
 #endif
 
+#if !defined(HAVE___DEV_UC_SYNC) && !defined(HAVE___DEV_MC_SYNC)
+
+#include <linux/netdevice.h>
+
+#define __hw_addr_sync_dev LINUX_BACKPORT(__hw_addr_sync_dev)
+int __hw_addr_sync_dev(struct netdev_hw_addr_list *list,
+                       struct net_device *dev,
+                       int (*sync)(struct net_device *, const unsigned char *),
+                       int (*unsync)(struct net_device *,
+                                     const unsigned char *));
+
+/**
+ *  __dev_uc_sync - Synchonize device's unicast list
+ *  @dev:  device to sync
+ *  @sync: function to call if address should be added
+ *  @unsync: function to call if address should be removed
+ *
+ *  Add newly added addresses to the interface, and release
+ *  addresses that have been deleted.
+ */
+#define __dev_uc_sync LINUX_BACKPORT(__dev_uc_sync)
+static inline int __dev_uc_sync(struct net_device *dev,
+                                int (*sync)(struct net_device *,
+                                            const unsigned char *),
+                                int (*unsync)(struct net_device *,
+                                              const unsigned char *))
+{
+        return __hw_addr_sync_dev(&dev->uc, dev, sync, unsync);
+}
+
+/**
+ *  __dev_mc_sync - Synchonize device's multicast list
+ *  @dev:  device to sync
+ *  @sync: function to call if address should be added
+ *  @unsync: function to call if address should be removed
+ *
+ *  Add newly added addresses to the interface, and release
+ *  addresses that have been deleted.
+ */
+#define __dev_mc_sync LINUX_BACKPORT(__dev_mc_sync)
+static inline int __dev_mc_sync(struct net_device *dev,
+                                int (*sync)(struct net_device *,
+                                            const unsigned char *),
+                                int (*unsync)(struct net_device *,
+                                              const unsigned char *))
+{
+        return __hw_addr_sync_dev(&dev->mc, dev, sync, unsync);
+}
+#endif
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0)) */
 
 #endif /* LINUX_3_16_COMPAT_H */
index e04eca9..7a9358f 100644 (file)
@@ -16,6 +16,7 @@
 #endif
 
 #include <linux/cpumask.h>
+#include <linux/if_vlan.h>
 
 #define cpumask_local_spread LINUX_BACKPORT(cpumask_local_spread)
 
@@ -28,6 +29,25 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node)
 unsigned int cpumask_local_spread(unsigned int i, int node);
 #endif
 
+#ifndef HAVE_SKB_VLAN_TAGGED
+/*
+ * skb_vlan_tagged - check if skb is vlan tagged.
+ * @skb: skbuff to query
+ *
+ * Returns true if the skb is tagged, regardless of whether it is hardware
+ * accelerated or not.
+ */
+static inline bool skb_vlan_tagged(const struct sk_buff *skb)
+{
+        if (!skb_vlan_tag_present(skb) &&
+            likely(skb->protocol != htons(ETH_P_8021Q) &&
+                   skb->protocol != htons(ETH_P_8021AD)))
+                return false;
+
+        return true;
+}
+#endif
+
 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(4,1,0)) */
 
 #endif /* LINUX_4_1_COMPAT_H */