--- /dev/null
+diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
+index 4512687..5a1bf82 100644
+--- a/drivers/infiniband/hw/cxgb4/cm.c
++++ b/drivers/infiniband/hw/cxgb4/cm.c
+@@ -363,6 +363,7 @@ static struct dst_entry *find_route6(struct c4iw_dev *dev, __u8 *local_ip,
+ struct dst_entry *dst = NULL;
+
+ if (IS_ENABLED(CONFIG_IPV6)) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
+ struct flowi6 fl6;
+
+ memset(&fl6, 0, sizeof(fl6));
+@@ -371,6 +372,18 @@ static struct dst_entry *find_route6(struct c4iw_dev *dev, __u8 *local_ip,
+ if (ipv6_addr_type(&fl6.daddr) & IPV6_ADDR_LINKLOCAL)
+ fl6.flowi6_oif = sin6_scope_id;
+ dst = ip6_route_output(&init_net, NULL, &fl6);
++#else
++ struct flowi fl;
++
++ memset(&fl, 0, sizeof(fl));
++ fl.proto = IPPROTO_TCP;
++ ipv6_addr_copy(&fl.fl6_src, (struct in6_addr *)local_ip);
++ ipv6_addr_copy(&fl.fl6_dst, (struct in6_addr *)peer_ip);
++ fl.fl_ip_dport = peer_port;
++ fl.fl_ip_sport = local_port;
++
++ dst = ip6_route_output(&init_net, NULL, &fl);
++#endif
+ if (!dst)
+ goto out;
+ if (!our_interface(dev, ip6_dst_idev(dst)->dev) &&
+@@ -389,6 +402,7 @@ static struct dst_entry *find_route(struct c4iw_dev *dev, __be32 local_ip,
+ __be16 peer_port, u8 tos)
+ {
+ struct rtable *rt;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
+ struct flowi4 fl4;
+ struct neighbour *n;
+
+@@ -397,7 +411,12 @@ static struct dst_entry *find_route(struct c4iw_dev *dev, __be32 local_ip,
+ tos, 0);
+ if (IS_ERR(rt))
+ return NULL;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
+ n = dst_neigh_lookup(&rt->dst, &peer_ip);
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
++ n = dst_get_neighbour(&rt->dst);
++#endif
+ if (!n)
+ return NULL;
+ if (!our_interface(dev, n->dev)) {
+@@ -406,6 +425,33 @@ static struct dst_entry *find_route(struct c4iw_dev *dev, __be32 local_ip,
+ }
+ neigh_release(n);
+ return &rt->dst;
++#else
++ struct flowi fl = {
++ .oif = 0,
++ .nl_u = {
++ .ip4_u = {
++ .daddr = peer_ip,
++ .saddr = local_ip,
++ .tos = tos}
++ },
++ .proto = IPPROTO_TCP,
++ .uli_u = {
++ .ports = {
++ .sport = local_port,
++ .dport = peer_port}
++ }
++ };
++
++ if (ip_route_output_flow(&init_net, &rt, &fl, NULL, 0))
++ return NULL;
++
++ if (!our_interface(dev, rt->u.dst.neighbour->dev) &&
++ !(rt->u.dst.neighbour->dev->flags & IFF_LOOPBACK)) {
++ dst_release(&rt->u.dst);
++ return NULL;
++ }
++ return &rt->u.dst;
++#endif
+ }
+
+ static void arp_failure_discard(void *handle, struct sk_buff *skb)
+@@ -1657,11 +1703,22 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip,
+ int err, step;
+ struct net_device *pdev;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
+ n = dst_neigh_lookup(dst, peer_ip);
+ if (!n)
+ return -ENODEV;
+
+ rcu_read_lock();
++#else
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 3, 0)
++ n = dst_get_neighbour_noref(dst);
++#else
++ n = dst_get_neighbour(dst);
++#endif
++ err = -ENODEV;
++ if (!n)
++ goto out;
++#endif
+ err = -ENOMEM;
+ if (n->dev->flags & IFF_LOOPBACK) {
+ if (iptype == 4)
+@@ -1723,7 +1780,9 @@ static int import_ep(struct c4iw_ep *ep, int iptype, __u8 *peer_ip,
+ out:
+ rcu_read_unlock();
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
+ neigh_release(n);
++#endif
+
+ return err;
+ }
+@@ -2649,7 +2708,11 @@ static int get_lladdr(struct net_device *dev, struct in6_addr *addr,
+ struct inet6_ifaddr *ifp;
+
+ read_lock_bh(&idev->lock);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
+ list_for_each_entry(ifp, &idev->addr_list, if_list) {
++#else
++ for (ifp=idev->addr_list; ifp; ifp=ifp->if_next) {
++#endif
+ if (ifp->scope == IFA_LINK &&
+ !(ifp->flags & banned_flags)) {
+ memcpy(addr, &ifp->addr, 16);
+@@ -3162,7 +3225,15 @@ static void build_cpl_pass_accept_req(struct sk_buff *skb, int stid , u8 tos)
+ */
+ memset(&tmp_opt, 0, sizeof(tmp_opt));
+ tcp_clear_options(&tmp_opt);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
+ tcp_parse_options(skb, &tmp_opt, 0, NULL);
++#else
++ tcp_parse_options(skb, &tmp_opt, 0, 0);
++#endif
++#else
++ tcp_parse_options(skb, &tmp_opt, 0);
++#endif
+
+ req = (struct cpl_pass_accept_req *)__skb_push(skb, sizeof(*req));
+ memset(req, 0, sizeof(*req));
+@@ -3324,7 +3395,15 @@ static int rx_pkt(struct c4iw_dev *dev, struct sk_buff *skb)
+ __func__);
+ goto reject;
+ }
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 1, 0)
+ neigh = dst_neigh_lookup_skb(dst, skb);
++#else
++ neigh = dst_get_neighbour(dst);
++#endif
++#else
++ neigh = dst->neighbour;
++#endif
+
+ if (!neigh) {
+ pr_err("%s - failed to allocate neigh!\n",
+diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+index 23eaeab..8fb094c 100644
+--- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
++++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h
+@@ -261,6 +261,7 @@ static inline int _insert_handle(struct c4iw_dev *rhp, struct idr *idr,
+ {
+ int ret;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
+ if (lock) {
+ idr_preload(GFP_KERNEL);
+ spin_lock_irq(&rhp->lock);
+@@ -275,6 +276,22 @@ static inline int _insert_handle(struct c4iw_dev *rhp, struct idr *idr,
+
+ BUG_ON(ret == -ENOSPC);
+ return ret < 0 ? ret : 0;
++#else
++ int newid;
++
++ do {
++ if (!idr_pre_get(idr, lock ? GFP_KERNEL : GFP_ATOMIC))
++ return -ENOMEM;
++ if (lock)
++ spin_lock_irq(&rhp->lock);
++ ret = idr_get_new_above(idr, handle, id, &newid);
++ BUG_ON(!ret && newid != id);
++ if (lock)
++ spin_unlock_irq(&rhp->lock);
++ } while (ret == -EAGAIN);
++
++ return ret;
++#endif
+ }
+
+ static inline int insert_handle(struct c4iw_dev *rhp, struct idr *idr,
+diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
+index 4cb8eb2..0804aca 100644
+--- a/drivers/infiniband/hw/cxgb4/mem.c
++++ b/drivers/infiniband/hw/cxgb4/mem.c
+@@ -34,6 +34,7 @@
+ #include <linux/moduleparam.h>
+ #include <rdma/ib_umem.h>
+ #include <linux/atomic.h>
++#include <linux/ratelimit.h>
+
+ #include "iw_cxgb4.h"
+