Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
---
- drivers/infiniband/ulp/ipoib/ipoib_main.c | 4 ++++
- 1 files changed, 4 insertions(+), 0 deletions(-)
+ drivers/infiniband/ulp/ipoib/ipoib.h | 3 ++
+ drivers/infiniband/ulp/ipoib/ipoib_cm.c | 8 +++++
+ drivers/infiniband/ulp/ipoib/ipoib_main.c | 41 ++++++++++++++++++++++++
+ drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 15 +++++++++
+ drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 8 +++++
+ 5 files changed, 75 insertions(+), 0 deletions(-)
+diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/ulp/ipoib/ipoib.h
++++ b/drivers/infiniband/ulp/ipoib/ipoib.h
+@@ -95,6 +95,9 @@ enum {
+ IPOIB_NEIGH_TBL_FLUSH = 12,
+
+ IPOIB_MAX_BACKOFF_SECONDS = 16,
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39))
++ IPOIB_FLAG_CSUM = 17,
++#endif
+
+ IPOIB_MCAST_FLAG_FOUND = 0, /* used in set_multicast_list */
+ IPOIB_MCAST_FLAG_SENDONLY = 1,
+diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
++++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+@@ -1394,7 +1394,11 @@ static void ipoib_cm_skb_reap(struct work_struct *work)
+ icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
+ #if IS_ENABLED(CONFIG_IPV6)
+ else if (skb->protocol == htons(ETH_P_IPV6))
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+ icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
++#else
++ icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, priv->dev);
++#endif
+ #endif
+ dev_kfree_skb_any(skb);
+
+@@ -1413,7 +1417,11 @@ void ipoib_cm_skb_too_long(struct net_device *dev, struct sk_buff *skb,
+ int e = skb_queue_empty(&priv->cm.skb_queue);
+
+ if (skb_dst(skb))
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+ skb_dst(skb)->ops->update_pmtu(skb_dst(skb), NULL, skb, mtu);
++#else
++ skb_dst(skb)->ops->update_pmtu(skb_dst(skb), mtu);
++#endif
+
+ skb_queue_tail(&priv->cm.skb_queue, skb);
+ if (e)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index xxxxxxx..xxxxxxx xxxxxx
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
-@@ -1364,7 +1364,11 @@ void ipoib_setup(struct net_device *dev)
+@@ -185,6 +185,7 @@ static void ipoib_uninit(struct net_device *dev)
+ ipoib_dev_cleanup(dev);
+ }
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+ static netdev_features_t ipoib_fix_features(struct net_device *dev, netdev_features_t features)
+ {
+ struct ipoib_dev_priv *priv = netdev_priv(dev);
+@@ -194,6 +195,7 @@ static netdev_features_t ipoib_fix_features(struct net_device *dev, netdev_featu
+
+ return features;
+ }
++#endif
+
+ static int ipoib_change_mtu(struct net_device *dev, int new_mtu)
+ {
+@@ -231,7 +233,14 @@ int ipoib_set_mode(struct net_device *dev, const char *buf)
+ set_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
+ ipoib_warn(priv, "enabling connected mode "
+ "will cause multicast packet drops\n");
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+ netdev_update_features(dev);
++#else
++ dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO);
++ if (ipoib_cm_max_mtu(dev) > priv->mcast_mtu)
++ ipoib_warn(priv, "mtu > %d will cause multicast packet drops.\n",
++ priv->mcast_mtu);
++#endif
+ rtnl_unlock();
+ priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM;
+
+@@ -242,7 +251,16 @@ int ipoib_set_mode(struct net_device *dev, const char *buf)
+
+ if (!strcmp(buf, "datagram\n")) {
+ clear_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+ netdev_update_features(dev);
++#else
++ if (test_bit(IPOIB_FLAG_CSUM, &priv->flags)) {
++ dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
++
++ if (priv->hca_caps & IB_DEVICE_UD_TSO)
++ dev->features |= NETIF_F_TSO;
++ }
++#endif
+ dev_set_mtu(dev, min(priv->mcast_mtu, dev->mtu));
+ rtnl_unlock();
+ ipoib_flush_paths(dev);
+@@ -1309,6 +1327,7 @@ void ipoib_dev_cleanup(struct net_device *dev)
+ ipoib_delete_debug_files(dev);
+
+ /* Delete any child interfaces first */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) {
+ /* Stop GC on child */
+ set_bit(IPOIB_STOP_NEIGH_GC, &cpriv->flags);
+@@ -1316,6 +1335,11 @@ void ipoib_dev_cleanup(struct net_device *dev)
+ unregister_netdevice_queue(cpriv->dev, &head);
+ }
+ unregister_netdevice_many(&head);
++#else
++ list_for_each_entry_safe(cpriv, tcpriv,
++ &priv->child_intfs, list)
++ unregister_netdevice(cpriv->dev);
++#endif
+
+ ipoib_ib_dev_cleanup(dev);
+
+@@ -1337,7 +1361,9 @@ static const struct net_device_ops ipoib_netdev_ops = {
+ .ndo_open = ipoib_open,
+ .ndo_stop = ipoib_stop,
+ .ndo_change_mtu = ipoib_change_mtu,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+ .ndo_fix_features = ipoib_fix_features,
++#endif
+ .ndo_start_xmit = ipoib_start_xmit,
+ .ndo_tx_timeout = ipoib_timeout,
+ .ndo_set_rx_mode = ipoib_set_mcast_list,
+@@ -1364,7 +1390,11 @@ void ipoib_setup(struct net_device *dev)
dev->tx_queue_len = ipoib_sendq_size * 2;
dev->features = (NETIF_F_VLAN_CHALLENGED |
NETIF_F_HIGHDMA);
memcpy(dev->broadcast, ipv4_bcast_addr, INFINIBAND_ALEN);
+@@ -1521,6 +1551,7 @@ int ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca)
+ kfree(device_attr);
+
+ if (priv->hca_caps & IB_DEVICE_UD_IP_CSUM) {
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39))
+ priv->dev->hw_features = NETIF_F_SG |
+ NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
+
+@@ -1528,6 +1559,14 @@ int ipoib_set_dev_features(struct ipoib_dev_priv *priv, struct ib_device *hca)
+ priv->dev->hw_features |= NETIF_F_TSO;
+
+ priv->dev->features |= priv->dev->hw_features;
++#else
++ set_bit(IPOIB_FLAG_CSUM, &priv->flags);
++ priv->dev->features |= NETIF_F_SG |
++ NETIF_F_IP_CSUM | NETIF_F_RXCSUM;
++
++ if (priv->hca_caps & IB_DEVICE_UD_TSO)
++ priv->dev->features |= NETIF_F_TSO;
++#endif
+ }
+
+ return 0;
+@@ -1559,7 +1598,9 @@ static struct net_device *ipoib_add_port(const char *format,
+ priv->dev->mtu = IPOIB_UD_MTU(priv->max_ib_mtu);
+ priv->mcast_mtu = priv->admin_mtu = priv->dev->mtu;
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+ priv->dev->neigh_priv_len = sizeof(struct ipoib_neigh);
++#endif
+
+ result = ib_query_pkey(hca, port, 0, &priv->pkey);
+ if (result) {
+diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
++++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+@@ -786,7 +786,11 @@ void ipoib_mcast_restart_task(struct work_struct *work)
+ struct ipoib_dev_priv *priv =
+ container_of(work, struct ipoib_dev_priv, restart_task);
+ struct net_device *dev = priv->dev;
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+ struct netdev_hw_addr *ha;
++#else
++ struct dev_mc_list *mclist;
++#endif
+ struct ipoib_mcast *mcast, *tmcast;
+ LIST_HEAD(remove_list);
+ unsigned long flags;
+@@ -811,6 +815,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)
+ clear_bit(IPOIB_MCAST_FLAG_FOUND, &mcast->flags);
+
+ /* Mark all of the entries that are found or don't exist */
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+ netdev_for_each_mc_addr(ha, dev) {
+ union ib_gid mgid;
+
+@@ -818,6 +823,16 @@ void ipoib_mcast_restart_task(struct work_struct *work)
+ continue;
+
+ memcpy(mgid.raw, ha->addr + 4, sizeof mgid);
++#else
++ for (mclist = dev->mc_list; mclist; mclist = mclist->next) {
++ union ib_gid mgid;
++
++ if (!ipoib_mcast_addr_is_valid(mclist->dmi_addr,
++ dev->broadcast))
++ continue;
++
++ memcpy(mgid.raw, mclist->dmi_addr + 4, sizeof mgid);
++#endif
+
+ mcast = __ipoib_mcast_find(dev, &mgid);
+ if (!mcast || test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
+diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
++++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c
+@@ -136,7 +136,11 @@ static int ipoib_new_child_link(struct net *src_net, struct net_device *dev,
+ return err;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ static void ipoib_unregister_child_dev(struct net_device *dev, struct list_head *head)
++#else
++static void ipoib_unregister_child_dev(struct net_device *dev)
++#endif
+ {
+ struct ipoib_dev_priv *priv, *ppriv;
+
+@@ -144,7 +148,11 @@ static void ipoib_unregister_child_dev(struct net_device *dev, struct list_head
+ ppriv = netdev_priv(priv->parent);
+
+ down_write(&ppriv->vlan_rwsem);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
+ unregister_netdevice_queue(dev, head);
++#else
++ unregister_netdevice(dev);
++#endif
+ list_del(&priv->list);
+ up_write(&ppriv->vlan_rwsem);
+ }
--- /dev/null
+From: Vladimir Sokolovsky <vlad@mellanox.com>
+Subject: [PATCH] BACKPORT: scsi/Makefile
+
+Avoid recompilation of the whole SCSI stack
+Leave only SRP related staff
+
+Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
+---
+ drivers/scsi/Makefile | 182 -------------------------------------------------
+ 1 files changed, 0 insertions(+), 182 deletions(-)
+
+diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/scsi/Makefile
++++ b/drivers/scsi/Makefile
+@@ -14,186 +14,4 @@
+ # *!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!
+
+
+-CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF
+-CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ -DGDTH_STATISTICS
+-
+-obj-$(CONFIG_PCMCIA) += pcmcia/
+-
+-obj-$(CONFIG_SCSI) += scsi_mod.o
+-
+-obj-$(CONFIG_RAID_ATTRS) += raid_class.o
+-
+-# --- NOTE ORDERING HERE ---
+-# For kernel non-modular link, transport attributes need to
+-# be initialised before drivers
+-# --------------------------
+-obj-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o
+-obj-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o
+-obj-$(CONFIG_SCSI_ISCSI_ATTRS) += scsi_transport_iscsi.o
+-obj-$(CONFIG_SCSI_SAS_ATTRS) += scsi_transport_sas.o
+-obj-$(CONFIG_SCSI_SAS_LIBSAS) += libsas/
+ obj-$(CONFIG_SCSI_SRP_ATTRS) += scsi_transport_srp.o
+-obj-$(CONFIG_SCSI_DH) += device_handler/
+-
+-obj-$(CONFIG_LIBFC) += libfc/
+-obj-$(CONFIG_LIBFCOE) += fcoe/
+-obj-$(CONFIG_FCOE) += fcoe/
+-obj-$(CONFIG_FCOE_FNIC) += fnic/
+-obj-$(CONFIG_SCSI_BNX2X_FCOE) += libfc/ fcoe/ bnx2fc/
+-obj-$(CONFIG_ISCSI_TCP) += libiscsi.o libiscsi_tcp.o iscsi_tcp.o
+-obj-$(CONFIG_INFINIBAND_ISER) += libiscsi.o
+-obj-$(CONFIG_ISCSI_BOOT_SYSFS) += iscsi_boot_sysfs.o
+-obj-$(CONFIG_SCSI_A4000T) += 53c700.o a4000t.o
+-obj-$(CONFIG_SCSI_ZORRO7XX) += 53c700.o zorro7xx.o
+-obj-$(CONFIG_A3000_SCSI) += a3000.o wd33c93.o
+-obj-$(CONFIG_A2091_SCSI) += a2091.o wd33c93.o
+-obj-$(CONFIG_GVP11_SCSI) += gvp11.o wd33c93.o
+-obj-$(CONFIG_MVME147_SCSI) += mvme147.o wd33c93.o
+-obj-$(CONFIG_SGIWD93_SCSI) += sgiwd93.o wd33c93.o
+-obj-$(CONFIG_ATARI_SCSI) += atari_scsi.o
+-obj-$(CONFIG_MAC_SCSI) += mac_scsi.o
+-obj-$(CONFIG_SCSI_MAC_ESP) += esp_scsi.o mac_esp.o
+-obj-$(CONFIG_SUN3_SCSI) += sun3_scsi.o sun3_scsi_vme.o
+-obj-$(CONFIG_MVME16x_SCSI) += 53c700.o mvme16x_scsi.o
+-obj-$(CONFIG_BVME6000_SCSI) += 53c700.o bvme6000_scsi.o
+-obj-$(CONFIG_SCSI_SIM710) += 53c700.o sim710.o
+-obj-$(CONFIG_SCSI_ADVANSYS) += advansys.o
+-obj-$(CONFIG_SCSI_BUSLOGIC) += BusLogic.o
+-obj-$(CONFIG_SCSI_DPT_I2O) += dpt_i2o.o
+-obj-$(CONFIG_SCSI_U14_34F) += u14-34f.o
+-obj-$(CONFIG_SCSI_ARCMSR) += arcmsr/
+-obj-$(CONFIG_SCSI_ULTRASTOR) += ultrastor.o
+-obj-$(CONFIG_SCSI_AHA152X) += aha152x.o
+-obj-$(CONFIG_SCSI_AHA1542) += aha1542.o
+-obj-$(CONFIG_SCSI_AHA1740) += aha1740.o
+-obj-$(CONFIG_SCSI_AIC7XXX) += aic7xxx/
+-obj-$(CONFIG_SCSI_AIC79XX) += aic7xxx/
+-obj-$(CONFIG_SCSI_AACRAID) += aacraid/
+-obj-$(CONFIG_SCSI_AIC94XX) += aic94xx/
+-obj-$(CONFIG_SCSI_PM8001) += pm8001/
+-obj-$(CONFIG_SCSI_ISCI) += isci/
+-obj-$(CONFIG_SCSI_IPS) += ips.o
+-obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
+-obj-$(CONFIG_SCSI_IN2000) += in2000.o
+-obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
+-obj-$(CONFIG_SCSI_GENERIC_NCR5380_MMIO) += g_NCR5380_mmio.o
+-obj-$(CONFIG_SCSI_NCR53C406A) += NCR53c406a.o
+-obj-$(CONFIG_SCSI_NCR_D700) += 53c700.o NCR_D700.o
+-obj-$(CONFIG_SCSI_NCR_Q720) += NCR_Q720_mod.o
+-obj-$(CONFIG_SCSI_SYM53C416) += sym53c416.o
+-obj-$(CONFIG_SCSI_QLOGIC_FAS) += qlogicfas408.o qlogicfas.o
+-obj-$(CONFIG_PCMCIA_QLOGIC) += qlogicfas408.o
+-obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o
+-obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx/
+-obj-$(CONFIG_SCSI_QLA_ISCSI) += libiscsi.o qla4xxx/
+-obj-$(CONFIG_SCSI_LPFC) += lpfc/
+-obj-$(CONFIG_SCSI_BFA_FC) += bfa/
+-obj-$(CONFIG_SCSI_CHELSIO_FCOE) += csiostor/
+-obj-$(CONFIG_SCSI_PAS16) += pas16.o
+-obj-$(CONFIG_SCSI_T128) += t128.o
+-obj-$(CONFIG_SCSI_DMX3191D) += dmx3191d.o
+-obj-$(CONFIG_SCSI_HPSA) += hpsa.o
+-obj-$(CONFIG_SCSI_DTC3280) += dtc.o
+-obj-$(CONFIG_SCSI_SYM53C8XX_2) += sym53c8xx_2/
+-obj-$(CONFIG_SCSI_ZALON) += zalon7xx.o
+-obj-$(CONFIG_SCSI_EATA_PIO) += eata_pio.o
+-obj-$(CONFIG_SCSI_7000FASST) += wd7000.o
+-obj-$(CONFIG_SCSI_EATA) += eata.o
+-obj-$(CONFIG_SCSI_DC395x) += dc395x.o
+-obj-$(CONFIG_SCSI_DC390T) += tmscsim.o
+-obj-$(CONFIG_MEGARAID_LEGACY) += megaraid.o
+-obj-$(CONFIG_MEGARAID_NEWGEN) += megaraid/
+-obj-$(CONFIG_MEGARAID_SAS) += megaraid/
+-obj-$(CONFIG_SCSI_MPT2SAS) += mpt2sas/
+-obj-$(CONFIG_SCSI_MPT3SAS) += mpt3sas/
+-obj-$(CONFIG_SCSI_UFSHCD) += ufs/
+-obj-$(CONFIG_SCSI_ACARD) += atp870u.o
+-obj-$(CONFIG_SCSI_SUNESP) += esp_scsi.o sun_esp.o
+-obj-$(CONFIG_SCSI_GDTH) += gdth.o
+-obj-$(CONFIG_SCSI_INITIO) += initio.o
+-obj-$(CONFIG_SCSI_INIA100) += a100u2w.o
+-obj-$(CONFIG_SCSI_QLOGICPTI) += qlogicpti.o
+-obj-$(CONFIG_SCSI_MESH) += mesh.o
+-obj-$(CONFIG_SCSI_MAC53C94) += mac53c94.o
+-obj-$(CONFIG_BLK_DEV_3W_XXXX_RAID) += 3w-xxxx.o
+-obj-$(CONFIG_SCSI_3W_9XXX) += 3w-9xxx.o
+-obj-$(CONFIG_SCSI_3W_SAS) += 3w-sas.o
+-obj-$(CONFIG_SCSI_PPA) += ppa.o
+-obj-$(CONFIG_SCSI_IMM) += imm.o
+-obj-$(CONFIG_JAZZ_ESP) += esp_scsi.o jazz_esp.o
+-obj-$(CONFIG_SUN3X_ESP) += esp_scsi.o sun3x_esp.o
+-obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o
+-obj-$(CONFIG_SCSI_SNI_53C710) += 53c700.o sni_53c710.o
+-obj-$(CONFIG_SCSI_NSP32) += nsp32.o
+-obj-$(CONFIG_SCSI_IPR) += ipr.o
+-obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/
+-obj-$(CONFIG_SCSI_IBMVFC) += ibmvscsi/
+-obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o
+-obj-$(CONFIG_SCSI_STEX) += stex.o
+-obj-$(CONFIG_SCSI_MVSAS) += mvsas/
+-obj-$(CONFIG_SCSI_MVUMI) += mvumi.o
+-obj-$(CONFIG_PS3_ROM) += ps3rom.o
+-obj-$(CONFIG_SCSI_CXGB3_ISCSI) += libiscsi.o libiscsi_tcp.o cxgbi/
+-obj-$(CONFIG_SCSI_CXGB4_ISCSI) += libiscsi.o libiscsi_tcp.o cxgbi/
+-obj-$(CONFIG_SCSI_BNX2_ISCSI) += libiscsi.o bnx2i/
+-obj-$(CONFIG_BE2ISCSI) += libiscsi.o be2iscsi/
+-obj-$(CONFIG_SCSI_ESAS2R) += esas2r/
+-obj-$(CONFIG_SCSI_PMCRAID) += pmcraid.o
+-obj-$(CONFIG_SCSI_VIRTIO) += virtio_scsi.o
+-obj-$(CONFIG_VMWARE_PVSCSI) += vmw_pvscsi.o
+-obj-$(CONFIG_XEN_SCSI_FRONTEND) += xen-scsifront.o
+-obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o
+-
+-obj-$(CONFIG_ARM) += arm/
+-
+-obj-$(CONFIG_CHR_DEV_ST) += st.o
+-obj-$(CONFIG_CHR_DEV_OSST) += osst.o
+-obj-$(CONFIG_BLK_DEV_SD) += sd_mod.o
+-obj-$(CONFIG_BLK_DEV_SR) += sr_mod.o
+-obj-$(CONFIG_CHR_DEV_SG) += sg.o
+-obj-$(CONFIG_CHR_DEV_SCH) += ch.o
+-obj-$(CONFIG_SCSI_ENCLOSURE) += ses.o
+-
+-obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/
+-
+-# This goes last, so that "real" scsi devices probe earlier
+-obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
+-
+-scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \
+- scsicam.o scsi_error.o scsi_lib.o
+-scsi_mod-$(CONFIG_SCSI_DMA) += scsi_lib_dma.o
+-scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o
+-scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o
+-scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o
+-scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o
+-scsi_mod-y += scsi_trace.o
+-scsi_mod-$(CONFIG_PM) += scsi_pm.o
+-
+-hv_storvsc-y := storvsc_drv.o
+-
+-sd_mod-objs := sd.o
+-sd_mod-$(CONFIG_BLK_DEV_INTEGRITY) += sd_dif.o
+-
+-sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
+-ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
+- := -DCONFIG_NCR53C8XX_PREFETCH -DSCSI_NCR_BIG_ENDIAN \
+- -DCONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
+-CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m)
+-zalon7xx-objs := zalon.o ncr53c8xx.o
+-NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o
+-oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o
+-
+-# Files generated that shall be removed upon make clean
+-clean-files := 53c700_d.h 53c700_u.h
+-
+-$(obj)/53c700.o $(MODVERDIR)/$(obj)/53c700.ver: $(obj)/53c700_d.h
+-
+-# If you want to play with the firmware, uncomment
+-# GENERATE_FIRMWARE := 1
+-
+-ifdef GENERATE_FIRMWARE
+-
+-$(obj)/53c700_d.h: $(src)/53c700.scr $(src)/script_asm.pl
+- $(PERL) -s $(src)/script_asm.pl -ncr7x0_family $@ $(@:_d.h=_u.h) < $<
+-
+-endif
+++ /dev/null
-From: Vladimir Sokolovsky <vlad@mellanox.com>
-Subject: [PATCH] scsi/Makefile: Avoid recompilation of the whole SCSI stack
-
-Leave only SRP related staff
-
-Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
----
- drivers/scsi/Makefile | 182 -------------------------------------------------
- 1 files changed, 0 insertions(+), 182 deletions(-)
-
-diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/scsi/Makefile
-+++ b/drivers/scsi/Makefile
-@@ -14,186 +14,4 @@
- # *!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!
-
-
--CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF
--CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ -DGDTH_STATISTICS
--
--obj-$(CONFIG_PCMCIA) += pcmcia/
--
--obj-$(CONFIG_SCSI) += scsi_mod.o
--
--obj-$(CONFIG_RAID_ATTRS) += raid_class.o
--
--# --- NOTE ORDERING HERE ---
--# For kernel non-modular link, transport attributes need to
--# be initialised before drivers
--# --------------------------
--obj-$(CONFIG_SCSI_SPI_ATTRS) += scsi_transport_spi.o
--obj-$(CONFIG_SCSI_FC_ATTRS) += scsi_transport_fc.o
--obj-$(CONFIG_SCSI_ISCSI_ATTRS) += scsi_transport_iscsi.o
--obj-$(CONFIG_SCSI_SAS_ATTRS) += scsi_transport_sas.o
--obj-$(CONFIG_SCSI_SAS_LIBSAS) += libsas/
- obj-$(CONFIG_SCSI_SRP_ATTRS) += scsi_transport_srp.o
--obj-$(CONFIG_SCSI_DH) += device_handler/
--
--obj-$(CONFIG_LIBFC) += libfc/
--obj-$(CONFIG_LIBFCOE) += fcoe/
--obj-$(CONFIG_FCOE) += fcoe/
--obj-$(CONFIG_FCOE_FNIC) += fnic/
--obj-$(CONFIG_SCSI_BNX2X_FCOE) += libfc/ fcoe/ bnx2fc/
--obj-$(CONFIG_ISCSI_TCP) += libiscsi.o libiscsi_tcp.o iscsi_tcp.o
--obj-$(CONFIG_INFINIBAND_ISER) += libiscsi.o
--obj-$(CONFIG_ISCSI_BOOT_SYSFS) += iscsi_boot_sysfs.o
--obj-$(CONFIG_SCSI_A4000T) += 53c700.o a4000t.o
--obj-$(CONFIG_SCSI_ZORRO7XX) += 53c700.o zorro7xx.o
--obj-$(CONFIG_A3000_SCSI) += a3000.o wd33c93.o
--obj-$(CONFIG_A2091_SCSI) += a2091.o wd33c93.o
--obj-$(CONFIG_GVP11_SCSI) += gvp11.o wd33c93.o
--obj-$(CONFIG_MVME147_SCSI) += mvme147.o wd33c93.o
--obj-$(CONFIG_SGIWD93_SCSI) += sgiwd93.o wd33c93.o
--obj-$(CONFIG_ATARI_SCSI) += atari_scsi.o
--obj-$(CONFIG_MAC_SCSI) += mac_scsi.o
--obj-$(CONFIG_SCSI_MAC_ESP) += esp_scsi.o mac_esp.o
--obj-$(CONFIG_SUN3_SCSI) += sun3_scsi.o sun3_scsi_vme.o
--obj-$(CONFIG_MVME16x_SCSI) += 53c700.o mvme16x_scsi.o
--obj-$(CONFIG_BVME6000_SCSI) += 53c700.o bvme6000_scsi.o
--obj-$(CONFIG_SCSI_SIM710) += 53c700.o sim710.o
--obj-$(CONFIG_SCSI_ADVANSYS) += advansys.o
--obj-$(CONFIG_SCSI_BUSLOGIC) += BusLogic.o
--obj-$(CONFIG_SCSI_DPT_I2O) += dpt_i2o.o
--obj-$(CONFIG_SCSI_U14_34F) += u14-34f.o
--obj-$(CONFIG_SCSI_ARCMSR) += arcmsr/
--obj-$(CONFIG_SCSI_ULTRASTOR) += ultrastor.o
--obj-$(CONFIG_SCSI_AHA152X) += aha152x.o
--obj-$(CONFIG_SCSI_AHA1542) += aha1542.o
--obj-$(CONFIG_SCSI_AHA1740) += aha1740.o
--obj-$(CONFIG_SCSI_AIC7XXX) += aic7xxx/
--obj-$(CONFIG_SCSI_AIC79XX) += aic7xxx/
--obj-$(CONFIG_SCSI_AACRAID) += aacraid/
--obj-$(CONFIG_SCSI_AIC94XX) += aic94xx/
--obj-$(CONFIG_SCSI_PM8001) += pm8001/
--obj-$(CONFIG_SCSI_ISCI) += isci/
--obj-$(CONFIG_SCSI_IPS) += ips.o
--obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
--obj-$(CONFIG_SCSI_IN2000) += in2000.o
--obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
--obj-$(CONFIG_SCSI_GENERIC_NCR5380_MMIO) += g_NCR5380_mmio.o
--obj-$(CONFIG_SCSI_NCR53C406A) += NCR53c406a.o
--obj-$(CONFIG_SCSI_NCR_D700) += 53c700.o NCR_D700.o
--obj-$(CONFIG_SCSI_NCR_Q720) += NCR_Q720_mod.o
--obj-$(CONFIG_SCSI_SYM53C416) += sym53c416.o
--obj-$(CONFIG_SCSI_QLOGIC_FAS) += qlogicfas408.o qlogicfas.o
--obj-$(CONFIG_PCMCIA_QLOGIC) += qlogicfas408.o
--obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o
--obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx/
--obj-$(CONFIG_SCSI_QLA_ISCSI) += libiscsi.o qla4xxx/
--obj-$(CONFIG_SCSI_LPFC) += lpfc/
--obj-$(CONFIG_SCSI_BFA_FC) += bfa/
--obj-$(CONFIG_SCSI_CHELSIO_FCOE) += csiostor/
--obj-$(CONFIG_SCSI_PAS16) += pas16.o
--obj-$(CONFIG_SCSI_T128) += t128.o
--obj-$(CONFIG_SCSI_DMX3191D) += dmx3191d.o
--obj-$(CONFIG_SCSI_HPSA) += hpsa.o
--obj-$(CONFIG_SCSI_DTC3280) += dtc.o
--obj-$(CONFIG_SCSI_SYM53C8XX_2) += sym53c8xx_2/
--obj-$(CONFIG_SCSI_ZALON) += zalon7xx.o
--obj-$(CONFIG_SCSI_EATA_PIO) += eata_pio.o
--obj-$(CONFIG_SCSI_7000FASST) += wd7000.o
--obj-$(CONFIG_SCSI_EATA) += eata.o
--obj-$(CONFIG_SCSI_DC395x) += dc395x.o
--obj-$(CONFIG_SCSI_DC390T) += tmscsim.o
--obj-$(CONFIG_MEGARAID_LEGACY) += megaraid.o
--obj-$(CONFIG_MEGARAID_NEWGEN) += megaraid/
--obj-$(CONFIG_MEGARAID_SAS) += megaraid/
--obj-$(CONFIG_SCSI_MPT2SAS) += mpt2sas/
--obj-$(CONFIG_SCSI_MPT3SAS) += mpt3sas/
--obj-$(CONFIG_SCSI_UFSHCD) += ufs/
--obj-$(CONFIG_SCSI_ACARD) += atp870u.o
--obj-$(CONFIG_SCSI_SUNESP) += esp_scsi.o sun_esp.o
--obj-$(CONFIG_SCSI_GDTH) += gdth.o
--obj-$(CONFIG_SCSI_INITIO) += initio.o
--obj-$(CONFIG_SCSI_INIA100) += a100u2w.o
--obj-$(CONFIG_SCSI_QLOGICPTI) += qlogicpti.o
--obj-$(CONFIG_SCSI_MESH) += mesh.o
--obj-$(CONFIG_SCSI_MAC53C94) += mac53c94.o
--obj-$(CONFIG_BLK_DEV_3W_XXXX_RAID) += 3w-xxxx.o
--obj-$(CONFIG_SCSI_3W_9XXX) += 3w-9xxx.o
--obj-$(CONFIG_SCSI_3W_SAS) += 3w-sas.o
--obj-$(CONFIG_SCSI_PPA) += ppa.o
--obj-$(CONFIG_SCSI_IMM) += imm.o
--obj-$(CONFIG_JAZZ_ESP) += esp_scsi.o jazz_esp.o
--obj-$(CONFIG_SUN3X_ESP) += esp_scsi.o sun3x_esp.o
--obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o
--obj-$(CONFIG_SCSI_SNI_53C710) += 53c700.o sni_53c710.o
--obj-$(CONFIG_SCSI_NSP32) += nsp32.o
--obj-$(CONFIG_SCSI_IPR) += ipr.o
--obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/
--obj-$(CONFIG_SCSI_IBMVFC) += ibmvscsi/
--obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o
--obj-$(CONFIG_SCSI_STEX) += stex.o
--obj-$(CONFIG_SCSI_MVSAS) += mvsas/
--obj-$(CONFIG_SCSI_MVUMI) += mvumi.o
--obj-$(CONFIG_PS3_ROM) += ps3rom.o
--obj-$(CONFIG_SCSI_CXGB3_ISCSI) += libiscsi.o libiscsi_tcp.o cxgbi/
--obj-$(CONFIG_SCSI_CXGB4_ISCSI) += libiscsi.o libiscsi_tcp.o cxgbi/
--obj-$(CONFIG_SCSI_BNX2_ISCSI) += libiscsi.o bnx2i/
--obj-$(CONFIG_BE2ISCSI) += libiscsi.o be2iscsi/
--obj-$(CONFIG_SCSI_ESAS2R) += esas2r/
--obj-$(CONFIG_SCSI_PMCRAID) += pmcraid.o
--obj-$(CONFIG_SCSI_VIRTIO) += virtio_scsi.o
--obj-$(CONFIG_VMWARE_PVSCSI) += vmw_pvscsi.o
--obj-$(CONFIG_XEN_SCSI_FRONTEND) += xen-scsifront.o
--obj-$(CONFIG_HYPERV_STORAGE) += hv_storvsc.o
--
--obj-$(CONFIG_ARM) += arm/
--
--obj-$(CONFIG_CHR_DEV_ST) += st.o
--obj-$(CONFIG_CHR_DEV_OSST) += osst.o
--obj-$(CONFIG_BLK_DEV_SD) += sd_mod.o
--obj-$(CONFIG_BLK_DEV_SR) += sr_mod.o
--obj-$(CONFIG_CHR_DEV_SG) += sg.o
--obj-$(CONFIG_CHR_DEV_SCH) += ch.o
--obj-$(CONFIG_SCSI_ENCLOSURE) += ses.o
--
--obj-$(CONFIG_SCSI_OSD_INITIATOR) += osd/
--
--# This goes last, so that "real" scsi devices probe earlier
--obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
--
--scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \
-- scsicam.o scsi_error.o scsi_lib.o
--scsi_mod-$(CONFIG_SCSI_DMA) += scsi_lib_dma.o
--scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o
--scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o
--scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o
--scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o
--scsi_mod-y += scsi_trace.o
--scsi_mod-$(CONFIG_PM) += scsi_pm.o
--
--hv_storvsc-y := storvsc_drv.o
--
--sd_mod-objs := sd.o
--sd_mod-$(CONFIG_BLK_DEV_INTEGRITY) += sd_dif.o
--
--sr_mod-objs := sr.o sr_ioctl.o sr_vendor.o
--ncr53c8xx-flags-$(CONFIG_SCSI_ZALON) \
-- := -DCONFIG_NCR53C8XX_PREFETCH -DSCSI_NCR_BIG_ENDIAN \
-- -DCONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
--CFLAGS_ncr53c8xx.o := $(ncr53c8xx-flags-y) $(ncr53c8xx-flags-m)
--zalon7xx-objs := zalon.o ncr53c8xx.o
--NCR_Q720_mod-objs := NCR_Q720.o ncr53c8xx.o
--oktagon_esp_mod-objs := oktagon_esp.o oktagon_io.o
--
--# Files generated that shall be removed upon make clean
--clean-files := 53c700_d.h 53c700_u.h
--
--$(obj)/53c700.o $(MODVERDIR)/$(obj)/53c700.ver: $(obj)/53c700_d.h
--
--# If you want to play with the firmware, uncomment
--# GENERATE_FIRMWARE := 1
--
--ifdef GENERATE_FIRMWARE
--
--$(obj)/53c700_d.h: $(src)/53c700.scr $(src)/script_asm.pl
-- $(PERL) -s $(src)/script_asm.pl -ncr7x0_family $@ $(@:_d.h=_u.h) < $<
--
--endif
--- /dev/null
+From: Vladimir Sokolovsky <vlad@mellanox.com>
+Subject: [PATCH] BACKPORT: ib-core for kernels under 3.10
+
+Slightly modified OFED-3.12-1 backports for the infininband/core
+to apply to linux-3.18
+
+Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
+Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.com>
+---
+ drivers/infiniband/core/addr.c | 105 +++++++++++++++++++++++++++++++++
+ drivers/infiniband/core/cm.c | 23 +++++++
+ drivers/infiniband/core/cma.c | 45 ++++++++++++++
+ drivers/infiniband/core/fmr_pool.c | 7 ++
+ drivers/infiniband/core/netlink.c | 20 ++++++
+ drivers/infiniband/core/sa_query.c | 15 +++++
+ drivers/infiniband/core/ucm.c | 38 ++++++++++++
+ drivers/infiniband/core/ucma.c | 76 ++++++++++++++++++++++++
+ drivers/infiniband/core/umem.c | 16 +++++
+ drivers/infiniband/core/user_mad.c | 16 +++++
+ drivers/infiniband/core/uverbs_cmd.c | 51 ++++++++++++++++
+ drivers/infiniband/core/uverbs_main.c | 40 +++++++++++++
+ 12 files changed, 452 insertions(+), 0 deletions(-)
+
+diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/addr.c
++++ b/drivers/infiniband/core/addr.c
+@@ -199,28 +199,45 @@ static void queue_req(struct addr_req *req)
+ mutex_unlock(&lock);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+ static int dst_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *dev_addr, void *daddr)
++#else
++static int dst_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *addr)
++#endif
+ {
+ struct neighbour *n;
+ int ret;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+ n = dst_neigh_lookup(dst, daddr);
++#endif
+
+ rcu_read_lock();
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
++ n = dst_get_neighbour(dst);
++#endif
+ if (!n || !(n->nud_state & NUD_VALID)) {
+ if (n)
+ neigh_event_send(n, NULL);
+ ret = -ENODATA;
+ } else {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+ ret = rdma_copy_addr(dev_addr, dst->dev, n->ha);
++#else
++ ret = rdma_copy_addr(addr, dst->dev, n->ha);
++#endif
+ }
+ rcu_read_unlock();
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+ if (n)
+ neigh_release(n);
++#endif
+
+ return ret;
+ }
++#endif
+
+ static int addr4_resolve(struct sockaddr_in *src_in,
+ struct sockaddr_in *dst_in,
+@@ -229,9 +246,15 @@ static int addr4_resolve(struct sockaddr_in *src_in,
+ __be32 src_ip = src_in->sin_addr.s_addr;
+ __be32 dst_ip = dst_in->sin_addr.s_addr;
+ struct rtable *rt;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+ struct flowi4 fl4;
++#else
++ struct flowi fl;
++ struct neighbour *neigh;
++#endif
+ int ret;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+ memset(&fl4, 0, sizeof(fl4));
+ fl4.daddr = dst_ip;
+ fl4.saddr = src_ip;
+@@ -241,10 +264,25 @@ static int addr4_resolve(struct sockaddr_in *src_in,
+ ret = PTR_ERR(rt);
+ goto out;
+ }
++#else
++ memset(&fl, 0, sizeof(fl));
++ fl.nl_u.ip4_u.daddr = dst_ip;
++ fl.nl_u.ip4_u.saddr = src_ip;
++ fl.oif = addr->bound_dev_if;
++ ret = ip_route_output_key(&init_net, &rt, &fl);
++ if (ret)
++ goto out;
++#endif
+ src_in->sin_family = AF_INET;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+ src_in->sin_addr.s_addr = fl4.saddr;
+
+ if (rt->dst.dev->flags & IFF_LOOPBACK) {
++#else
++ src_in->sin_addr.s_addr = rt->rt_src;
++
++ if (rt->idev->dev->flags & IFF_LOOPBACK) {
++#endif
+ ret = rdma_translate_ip((struct sockaddr *)dst_in, addr, NULL);
+ if (!ret)
+ memcpy(addr->dst_dev_addr, addr->src_dev_addr, MAX_ADDR_LEN);
+@@ -252,12 +290,37 @@ static int addr4_resolve(struct sockaddr_in *src_in,
+ }
+
+ /* If the device does ARP internally, return 'done' */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+ if (rt->dst.dev->flags & IFF_NOARP) {
+ ret = rdma_copy_addr(addr, rt->dst.dev, NULL);
+ goto put;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+ ret = dst_fetch_ha(&rt->dst, addr, &fl4.daddr);
++#else
++ ret = dst_fetch_ha(&rt->dst, addr);
++#endif
++#else
++ if (rt->idev->dev->flags & IFF_NOARP) {
++ ret = rdma_copy_addr(addr, rt->idev->dev, NULL);
++ goto put;
++ }
++
++ neigh = neigh_lookup(&arp_tbl, &rt->rt_gateway, rt->idev->dev);
++ if (!neigh || !(neigh->nud_state & NUD_VALID)) {
++ neigh_event_send(rt->u.dst.neighbour, NULL);
++ ret = -ENODATA;
++ if (neigh)
++ goto release;
++ goto put;
++ }
++
++ ret = rdma_copy_addr(addr, neigh->dev, neigh->ha);
++release:
++ neigh_release(neigh);
++#endif
++
+ put:
+ ip_rt_put(rt);
+ out:
+@@ -269,10 +332,16 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
+ struct sockaddr_in6 *dst_in,
+ struct rdma_dev_addr *addr)
+ {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+ struct flowi6 fl6;
++#else
++ struct flowi fl;
++ struct neighbour *neigh;
++#endif
+ struct dst_entry *dst;
+ int ret;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+ memset(&fl6, 0, sizeof fl6);
+ fl6.daddr = dst_in->sin6_addr;
+ fl6.saddr = src_in->sin6_addr;
+@@ -291,6 +360,26 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
+ src_in->sin6_family = AF_INET6;
+ src_in->sin6_addr = fl6.saddr;
+ }
++#else
++ memset(&fl, 0, sizeof fl);
++ ipv6_addr_copy(&fl.fl6_dst, &dst_in->sin6_addr);
++ ipv6_addr_copy(&fl.fl6_src, &src_in->sin6_addr);
++ fl.oif = addr->bound_dev_if;
++
++ dst = ip6_route_output(&init_net, NULL, &fl);
++ if ((ret = dst->error))
++ goto put;
++
++ if (ipv6_addr_any(&fl.fl6_src)) {
++ ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
++ &fl.fl6_dst, 0, &fl.fl6_src);
++ if (ret)
++ goto put;
++
++ src_in->sin6_family = AF_INET6;
++ ipv6_addr_copy(&src_in->sin6_addr, &fl.fl6_src);
++ }
++#endif
+
+ if (dst->dev->flags & IFF_LOOPBACK) {
+ ret = rdma_translate_ip((struct sockaddr *)dst_in, addr, NULL);
+@@ -305,7 +394,23 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
+ goto put;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+ ret = dst_fetch_ha(dst, addr, &fl6.daddr);
++#else
++ ret = dst_fetch_ha(dst, addr);
++#endif
++#else
++ neigh = dst->neighbour;
++ if (!neigh || !(neigh->nud_state & NUD_VALID)) {
++ neigh_event_send(dst->neighbour, NULL);
++ ret = -ENODATA;
++ goto put;
++ }
++
++ ret = rdma_copy_addr(addr, dst->dev, neigh->ha);
++#endif
++
+ put:
+ dst_release(dst);
+ return ret;
+diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/cm.c
++++ b/drivers/infiniband/core/cm.c
+@@ -387,6 +387,7 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
+
+ static int cm_alloc_id(struct cm_id_private *cm_id_priv)
+ {
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
+ unsigned long flags;
+ int id;
+
+@@ -400,6 +401,24 @@ static int cm_alloc_id(struct cm_id_private *cm_id_priv)
+
+ cm_id_priv->id.local_id = (__force __be32)id ^ cm.random_id_operand;
+ return id < 0 ? id : 0;
++#else
++ unsigned long flags;
++ int ret, id;
++ static int next_id;
++
++ do {
++ spin_lock_irqsave(&cm.lock, flags);
++ ret = idr_get_new_above(&cm.local_id_table, cm_id_priv,
++ next_id, &id);
++ if (!ret)
++ next_id = ((unsigned) id + 1) & MAX_IDR_MASK;
++
++ spin_unlock_irqrestore(&cm.lock, flags);
++ } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );
++
++ cm_id_priv->id.local_id = (__force __be32)id ^ cm.random_id_operand;
++ return ret;
++#endif
+ }
+
+ static void cm_free_id(__be32 local_id)
+@@ -3692,7 +3711,11 @@ static struct kobj_type cm_port_obj_type = {
+ .release = cm_release_port_obj
+ };
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+ static char *cm_devnode(struct device *dev, umode_t *mode)
++#else
++static char *cm_devnode(struct device *dev, mode_t *mode)
++#endif
+ {
+ if (mode)
+ *mode = 0666;
+diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/cma.c
++++ b/drivers/infiniband/core/cma.c
+@@ -1867,6 +1867,7 @@ static int cma_resolve_iw_route(struct rdma_id_private *id_priv, int timeout_ms)
+ #if defined(HAVE_VLAN_DEV_GET_EGRESS_QOS_MASK) && defined(HAVE_NETDEV_GET_PRIO_TC_MAP)
+ static int iboe_tos_to_sl(struct net_device *ndev, int tos)
+ {
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
+ int prio;
+ struct net_device *dev;
+
+@@ -1882,6 +1883,7 @@ static int iboe_tos_to_sl(struct net_device *ndev, int tos)
+ return (vlan_dev_get_egress_qos_mask(ndev, prio) &
+ VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
+ #endif
++#endif
+ return 0;
+ }
+ #endif
+@@ -2315,6 +2317,7 @@ static int cma_alloc_port(struct idr *ps, struct rdma_id_private *id_priv,
+ unsigned short snum)
+ {
+ struct rdma_bind_list *bind_list;
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
+ int ret;
+
+ bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL);
+@@ -2332,6 +2335,35 @@ static int cma_alloc_port(struct idr *ps, struct rdma_id_private *id_priv,
+ err:
+ kfree(bind_list);
+ return ret == -ENOSPC ? -EADDRNOTAVAIL : ret;
++#else
++ int port, ret;
++
++ bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL);
++ if (!bind_list)
++ return -ENOMEM;
++
++ do {
++ ret = idr_get_new_above(ps, bind_list, snum, &port);
++ } while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL));
++
++ if (ret)
++ goto err1;
++
++ if (port != snum) {
++ ret = -EADDRNOTAVAIL;
++ goto err2;
++ }
++
++ bind_list->ps = ps;
++ bind_list->port = (unsigned short) port;
++ cma_bind_port(bind_list, id_priv);
++ return 0;
++err2:
++ idr_remove(ps, port);
++err1:
++ kfree(bind_list);
++ return ret;
++#endif
+ }
+
+ static int cma_alloc_any_port(struct idr *ps, struct rdma_id_private *id_priv)
+@@ -2380,9 +2412,16 @@ static int cma_check_port(struct rdma_bind_list *bind_list,
+ {
+ struct rdma_id_private *cur_id;
+ struct sockaddr *addr, *cur_addr;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++ struct hlist_node *node;
++#endif
+
+ addr = cma_src_addr(id_priv);
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++ hlist_for_each_entry(cur_id, node, &bind_list->owners, node) {
++#else
+ hlist_for_each_entry(cur_id, &bind_list->owners, node) {
++#endif
+ if (id_priv == cur_id)
+ continue;
+
+@@ -3470,9 +3509,15 @@ static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id
+ }
+
+ static int cma_netdev_callback(struct notifier_block *self, unsigned long event,
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
+ void *ptr)
+ {
+ struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
++#else
++ void *ctx)
++{
++ struct net_device *ndev = (struct net_device *)ctx;
++#endif
+ struct cma_device *cma_dev;
+ struct rdma_id_private *id_priv;
+ int ret = NOTIFY_DONE;
+diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/fmr_pool.c
++++ b/drivers/infiniband/core/fmr_pool.c
+@@ -118,13 +118,20 @@ static inline struct ib_pool_fmr *ib_fmr_cache_lookup(struct ib_fmr_pool *pool,
+ {
+ struct hlist_head *bucket;
+ struct ib_pool_fmr *fmr;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++ struct hlist_node *pos;
++#endif
+
+ if (!pool->cache_bucket)
+ return NULL;
+
+ bucket = pool->cache_bucket + ib_fmr_hash(*page_list);
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++ hlist_for_each_entry(fmr, pos, bucket, cache_node)
++#else
+ hlist_for_each_entry(fmr, bucket, cache_node)
++#endif
+ if (io_virtual_address == fmr->io_virtual_address &&
+ page_list_len == fmr->page_list_len &&
+ !memcmp(page_list, fmr->page_list,
+diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/netlink.c
++++ b/drivers/infiniband/core/netlink.c
+@@ -30,6 +30,9 @@
+ * SOFTWARE.
+ */
+
++#ifdef pr_fmt
++#undef pr_fmt
++#endif
+ #define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
+
+ #include <linux/export.h>
+@@ -152,11 +155,19 @@ static int ibnl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
+ return -EINVAL;
+
+ {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0) || defined(CONFIG_COMPAT_NETLINK_3_7)
+ struct netlink_dump_control c = {
+ .dump = client->cb_table[op].dump,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) || defined(CONFIG_COMPAT_NETLINK_3_7)
+ .module = client->cb_table[op].module,
++#endif
+ };
+ return netlink_dump_start(nls, skb, nlh, &c);
++#else
++ return netlink_dump_start(nls, skb, nlh,
++ client->cb_table[op].dump,
++ NULL, 0);
++#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) */
+ }
+ }
+ }
+@@ -188,11 +199,20 @@ EXPORT_SYMBOL(ibnl_multicast);
+
+ int __init ibnl_init(void)
+ {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
+ struct netlink_kernel_cfg cfg = {
+ .input = ibnl_rcv,
+ };
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ nls = netlink_kernel_create(&init_net, NETLINK_RDMA, &cfg);
++#else
++ nls = netlink_kernel_create(&init_net, NETLINK_RDMA, THIS_MODULE, &cfg);
++#endif
++#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
++ nls = netlink_kernel_create(&init_net, NETLINK_RDMA, 0, ibnl_rcv,
++ NULL, THIS_MODULE);
++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
+ if (!nls) {
+ pr_warn("Failed to create netlink socket\n");
+ return -ENOMEM;
+diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/sa_query.c
++++ b/drivers/infiniband/core/sa_query.c
+@@ -618,10 +618,13 @@ static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent)
+
+ static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask)
+ {
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
+ bool preload = !!(gfp_mask & __GFP_WAIT);
++#endif
+ unsigned long flags;
+ int ret, id;
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
+ if (preload)
+ idr_preload(gfp_mask);
+ spin_lock_irqsave(&idr_lock, flags);
+@@ -633,6 +636,18 @@ static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask)
+ idr_preload_end();
+ if (id < 0)
+ return id;
++#else
++retry:
++ if (!idr_pre_get(&query_idr, gfp_mask))
++ return -ENOMEM;
++ spin_lock_irqsave(&idr_lock, flags);
++ ret = idr_get_new(&query_idr, query, &id);
++ spin_unlock_irqrestore(&idr_lock, flags);
++ if (ret == -EAGAIN)
++ goto retry;
++ if (ret)
++ return ret;
++#endif
+
+ query->mad_buf->timeout_ms = timeout_ms;
+ query->mad_buf->context[0] = query;
+diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/ucm.c
++++ b/drivers/infiniband/core/ucm.c
+@@ -176,6 +176,9 @@ static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx)
+ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
+ {
+ struct ib_ucm_context *ctx;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
++ int result;
++#endif
+
+ ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
+ if (!ctx)
+@@ -186,11 +189,26 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
+ ctx->file = file;
+ INIT_LIST_HEAD(&ctx->events);
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
+ mutex_lock(&ctx_id_mutex);
+ ctx->id = idr_alloc(&ctx_id_table, ctx, 0, 0, GFP_KERNEL);
+ mutex_unlock(&ctx_id_mutex);
+ if (ctx->id < 0)
+ goto error;
++#else
++ do {
++ result = idr_pre_get(&ctx_id_table, GFP_KERNEL);
++ if (!result)
++ goto error;
++
++ mutex_lock(&ctx_id_mutex);
++ result = idr_get_new(&ctx_id_table, ctx, &ctx->id);
++ mutex_unlock(&ctx_id_mutex);
++ } while (result == -EAGAIN);
++
++ if (result)
++ goto error;
++#endif
+
+ list_add_tail(&ctx->file_list, &file->ctxs);
+ return ctx;
+@@ -1321,8 +1339,16 @@ static void ib_ucm_remove_one(struct ib_device *device)
+ device_unregister(&ucm_dev->dev);
+ }
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+ static CLASS_ATTR_STRING(abi_version, S_IRUGO,
+ __stringify(IB_USER_CM_ABI_VERSION));
++#else
++static ssize_t show_abi_version(struct class *class, char *buf)
++{
++ return sprintf(buf, "%d\n", IB_USER_CM_ABI_VERSION);
++}
++static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
++#endif
+
+ static int __init ib_ucm_init(void)
+ {
+@@ -1335,7 +1361,11 @@ static int __init ib_ucm_init(void)
+ goto error1;
+ }
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+ ret = class_create_file(&cm_class, &class_attr_abi_version.attr);
++#else
++ ret = class_create_file(&cm_class, &class_attr_abi_version);
++#endif
+ if (ret) {
+ printk(KERN_ERR "ucm: couldn't create abi_version attribute\n");
+ goto error2;
+@@ -1349,7 +1379,11 @@ static int __init ib_ucm_init(void)
+ return 0;
+
+ error3:
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+ class_remove_file(&cm_class, &class_attr_abi_version.attr);
++#else
++ class_remove_file(&cm_class, &class_attr_abi_version);
++#endif
+ error2:
+ unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
+ error1:
+@@ -1359,7 +1393,11 @@ error1:
+ static void __exit ib_ucm_cleanup(void)
+ {
+ ib_unregister_client(&ucm_client);
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+ class_remove_file(&cm_class, &class_attr_abi_version.attr);
++#else
++ class_remove_file(&cm_class, &class_attr_abi_version);
++#endif
+ unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
+ if (overflow_maj)
+ unregister_chrdev_region(overflow_maj, IB_UCM_MAX_DEVICES);
+diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/ucma.c
++++ b/drivers/infiniband/core/ucma.c
+@@ -56,6 +56,7 @@ MODULE_LICENSE("Dual BSD/GPL");
+
+ static unsigned int max_backlog = 1024;
+
++#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
+ static struct ctl_table_header *ucma_ctl_table_hdr;
+ static struct ctl_table ucma_ctl_table[] = {
+ {
+@@ -67,6 +68,14 @@ static struct ctl_table ucma_ctl_table[] = {
+ },
+ { }
+ };
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
++static struct ctl_path ucma_ctl_path[] = {
++ { .procname = "net" },
++ { .procname = "rdma_ucm" },
++ { }
++};
++#endif
++#endif
+
+ struct ucma_file {
+ struct mutex mut;
+@@ -147,6 +156,9 @@ static void ucma_put_ctx(struct ucma_context *ctx)
+ static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
+ {
+ struct ucma_context *ctx;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
++ int ret;
++#endif
+
+ ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ if (!ctx)
+@@ -157,11 +169,26 @@ static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
+ INIT_LIST_HEAD(&ctx->mc_list);
+ ctx->file = file;
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
++ do {
++ ret = idr_pre_get(&ctx_idr, GFP_KERNEL);
++ if (!ret)
++ goto error;
++
++ mutex_lock(&mut);
++ ret = idr_get_new(&ctx_idr, ctx, &ctx->id);
++ mutex_unlock(&mut);
++ } while (ret == -EAGAIN);
++
++ if (ret)
++ goto error;
++#else
+ mutex_lock(&mut);
+ ctx->id = idr_alloc(&ctx_idr, ctx, 0, 0, GFP_KERNEL);
+ mutex_unlock(&mut);
+ if (ctx->id < 0)
+ goto error;
++#endif
+
+ list_add_tail(&ctx->list, &file->ctx_list);
+ return ctx;
+@@ -174,16 +201,34 @@ error:
+ static struct ucma_multicast* ucma_alloc_multicast(struct ucma_context *ctx)
+ {
+ struct ucma_multicast *mc;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
++ int ret;
++#endif
+
+ mc = kzalloc(sizeof(*mc), GFP_KERNEL);
+ if (!mc)
+ return NULL;
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
++ do {
++ ret = idr_pre_get(&multicast_idr, GFP_KERNEL);
++ if (!ret)
++ goto error;
++
++ mutex_lock(&mut);
++ ret = idr_get_new(&multicast_idr, mc, &mc->id);
++ mutex_unlock(&mut);
++ } while (ret == -EAGAIN);
++
++ if (ret)
++ goto error;
++#else
+ mutex_lock(&mut);
+ mc->id = idr_alloc(&multicast_idr, mc, 0, 0, GFP_KERNEL);
+ mutex_unlock(&mut);
+ if (mc->id < 0)
+ goto error;
++#endif
+
+ mc->ctx = ctx;
+ list_add_tail(&mc->list, &ctx->mc_list);
+@@ -1398,7 +1443,11 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
+ struct rdma_ucm_migrate_id cmd;
+ struct rdma_ucm_migrate_resp resp;
+ struct ucma_context *ctx;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ struct fd f;
++#else
++ struct file *filp;
++#endif
+ struct ucma_file *cur_file;
+ int ret = 0;
+
+@@ -1406,12 +1455,21 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
+ return -EFAULT;
+
+ /* Get current fd to protect against it being closed */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ f = fdget(cmd.fd);
+ if (!f.file)
++#else
++ filp = fget(cmd.fd);
++ if (!filp)
++#endif
+ return -ENOENT;
+
+ /* Validate current fd and prevent destruction of id. */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ ctx = ucma_get_ctx(f.file->private_data, cmd.id);
++#else
++ ctx = ucma_get_ctx(filp->private_data, cmd.id);
++#endif
+ if (IS_ERR(ctx)) {
+ ret = PTR_ERR(ctx);
+ goto file_put;
+@@ -1445,7 +1503,11 @@ response:
+
+ ucma_put_ctx(ctx);
+ file_put:
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ fdput(f);
++#else
++ fput(filp);
++#endif
+ return ret;
+ }
+
+@@ -1606,15 +1668,23 @@ static int __init ucma_init(void)
+ goto err1;
+ }
+
++#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
+ ucma_ctl_table_hdr = register_net_sysctl(&init_net, "net/rdma_ucm", ucma_ctl_table);
++#else
++ ucma_ctl_table_hdr = register_sysctl_paths(ucma_ctl_path, ucma_ctl_table);
++#endif
+ if (!ucma_ctl_table_hdr) {
+ printk(KERN_ERR "rdma_ucm: couldn't register sysctl paths\n");
+ ret = -ENOMEM;
+ goto err2;
+ }
++#endif
+ return 0;
++#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
+ err2:
+ device_remove_file(ucma_misc.this_device, &dev_attr_abi_version);
++#endif
+ err1:
+ misc_deregister(&ucma_misc);
+ return ret;
+@@ -1622,7 +1692,13 @@ err1:
+
+ static void __exit ucma_cleanup(void)
+ {
++#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
+ unregister_net_sysctl_table(ucma_ctl_table_hdr);
++#else
++ unregister_sysctl_table(ucma_ctl_table_hdr);
++#endif
++#endif
+ device_remove_file(ucma_misc.this_device, &dev_attr_abi_version);
+ misc_deregister(&ucma_misc);
+ idr_destroy(&ctx_idr);
+diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/umem.c
++++ b/drivers/infiniband/core/umem.c
+@@ -136,7 +136,11 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
+
+ down_write(¤t->mm->mmap_sem);
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+ locked = npages + current->mm->pinned_vm;
++#else
++ locked = npages + current->mm->locked_vm;
++#endif
+ lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
+
+ if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) {
+@@ -202,7 +206,11 @@ out:
+ put_pid(umem->pid);
+ kfree(umem);
+ } else
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+ current->mm->pinned_vm = locked;
++#else
++ current->mm->locked_vm = locked;
++#endif
+
+ up_write(¤t->mm->mmap_sem);
+ if (vma_list)
+@@ -218,7 +226,11 @@ static void ib_umem_account(struct work_struct *work)
+ struct ib_umem *umem = container_of(work, struct ib_umem, work);
+
+ down_write(&umem->mm->mmap_sem);
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+ umem->mm->pinned_vm -= umem->diff;
++#else
++ umem->mm->locked_vm -= umem->diff;
++#endif
+ up_write(&umem->mm->mmap_sem);
+ mmput(umem->mm);
+ kfree(umem);
+@@ -268,7 +280,11 @@ void ib_umem_release(struct ib_umem *umem)
+ } else
+ down_write(&mm->mmap_sem);
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
+ mm->pinned_vm -= diff;
++#else
++ mm->locked_vm -= diff;
++#endif
+ up_write(&mm->mmap_sem);
+ mmput(mm);
+ out:
+diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/user_mad.c
++++ b/drivers/infiniband/core/user_mad.c
+@@ -1117,8 +1117,16 @@ static ssize_t show_port(struct device *dev, struct device_attribute *attr,
+ }
+ static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+ static CLASS_ATTR_STRING(abi_version, S_IRUGO,
+ __stringify(IB_USER_MAD_ABI_VERSION));
++#else
++static ssize_t show_abi_version(struct class *class, char *buf)
++{
++ return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION);
++}
++static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
++#endif
+
+ static dev_t overflow_maj;
+ static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS);
+@@ -1328,7 +1336,11 @@ static void ib_umad_remove_one(struct ib_device *device)
+ kobject_put(&umad_dev->kobj);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+ static char *umad_devnode(struct device *dev, umode_t *mode)
++#else
++static char *umad_devnode(struct device *dev, mode_t *mode)
++#endif
+ {
+ return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
+ }
+@@ -1353,7 +1365,11 @@ static int __init ib_umad_init(void)
+
+ umad_class->devnode = umad_devnode;
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+ ret = class_create_file(umad_class, &class_attr_abi_version.attr);
++#else
++ ret = class_create_file(umad_class, &class_attr_abi_version);
++#endif
+ if (ret) {
+ pr_err("couldn't create abi_version attribute\n");
+ goto out_class;
+diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/uverbs_cmd.c
++++ b/drivers/infiniband/core/uverbs_cmd.c
+@@ -119,6 +119,7 @@ static int idr_add_uobj(struct idr *idr, struct ib_uobject *uobj)
+ {
+ int ret;
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
+ idr_preload(GFP_KERNEL);
+ spin_lock(&ib_uverbs_idr_lock);
+
+@@ -130,6 +131,20 @@ static int idr_add_uobj(struct idr *idr, struct ib_uobject *uobj)
+ idr_preload_end();
+
+ return ret < 0 ? ret : 0;
++#else
++retry:
++ if (!idr_pre_get(idr, GFP_KERNEL))
++ return -ENOMEM;
++
++ spin_lock(&ib_uverbs_idr_lock);
++ ret = idr_get_new(idr, uobj, &uobj->id);
++ spin_unlock(&ib_uverbs_idr_lock);
++
++ if (ret == -EAGAIN)
++ goto retry;
++
++ return ret;
++#endif
+ }
+
+ void idr_remove_uobj(struct idr *idr, struct ib_uobject *uobj)
+@@ -329,7 +344,11 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
+
+ resp.num_comp_vectors = file->device->num_comp_vectors;
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
+ ret = get_unused_fd_flags(O_CLOEXEC);
++#else
++ ret = get_unused_fd();
++#endif
+ if (ret < 0)
+ goto err_free;
+ resp.async_fd = ret;
+@@ -700,7 +719,11 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
+ struct ib_udata udata;
+ struct ib_uxrcd_object *obj;
+ struct ib_xrcd *xrcd = NULL;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ struct fd f = {NULL, 0};
++#else
++ struct file *f = NULL;
++#endif
+ struct inode *inode = NULL;
+ int ret = 0;
+ int new_xrcd = 0;
+@@ -719,6 +742,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
+
+ if (cmd.fd != -1) {
+ /* search for file descriptor */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ f = fdget(cmd.fd);
+ if (!f.file) {
+ ret = -EBADF;
+@@ -726,6 +750,19 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
+ }
+
+ inode = file_inode(f.file);
++#else
++ f = fget(cmd.fd);
++ if (!f) {
++ ret = -EBADF;
++ goto err_tree_mutex_unlock;
++ }
++
++ inode = f->f_dentry->d_inode;
++ if (!inode) {
++ ret = -EBADF;
++ goto err_tree_mutex_unlock;
++ }
++#endif
+ xrcd = find_xrcd(file->device, inode);
+ if (!xrcd && !(cmd.oflags & O_CREAT)) {
+ /* no file descriptor. Need CREATE flag */
+@@ -790,8 +827,13 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
+ goto err_copy;
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ if (f.file)
+ fdput(f);
++#else
++ if (f)
++ fput(f);
++#endif
+
+ mutex_lock(&file->mutex);
+ list_add_tail(&obj->uobject.list, &file->ucontext->xrcd_list);
+@@ -820,8 +862,13 @@ err:
+ put_uobj_write(&obj->uobject);
+
+ err_tree_mutex_unlock:
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ if (f.file)
+ fdput(f);
++#else
++ if (f)
++ fput(f);
++#endif
+
+ mutex_unlock(&file->device->xrcd_tree_mutex);
+
+@@ -1268,7 +1315,11 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
+ if (copy_from_user(&cmd, buf, sizeof cmd))
+ return -EFAULT;
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
+ ret = get_unused_fd_flags(O_CLOEXEC);
++#else
++ ret = get_unused_fd();
++#endif
+ if (ret < 0)
+ return ret;
+ resp.fd = ret;
+diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/uverbs_main.c
++++ b/drivers/infiniband/core/uverbs_main.c
+@@ -572,6 +572,7 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
+ struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd)
+ {
+ struct ib_uverbs_event_file *ev_file = NULL;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
+ struct fd f = fdget(fd);
+
+ if (!f.file)
+@@ -591,6 +592,29 @@ struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd)
+ out:
+ fdput(f);
+ return ev_file;
++#else
++ struct file *filp;
++ int fput_needed;
++
++ filp = fget_light(fd, &fput_needed);
++ if (!filp)
++ return NULL;
++
++ if (filp->f_op != &uverbs_event_fops)
++ goto out;
++
++ ev_file = filp->private_data;
++ if (ev_file->is_async) {
++ ev_file = NULL;
++ goto out;
++ }
++
++ kref_get(&ev_file->ref);
++
++out:
++ fput_light(filp, fput_needed);
++ return ev_file;
++#endif
+ }
+
+ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
+@@ -834,8 +858,16 @@ static ssize_t show_dev_abi_version(struct device *device,
+ }
+ static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL);
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+ static CLASS_ATTR_STRING(abi_version, S_IRUGO,
+ __stringify(IB_USER_VERBS_ABI_VERSION));
++#else
++static ssize_t show_abi_version(struct class *class, char *buf)
++{
++ return sprintf(buf, "%d\n", IB_USER_VERBS_ABI_VERSION);
++}
++static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
++#endif
+
+ static dev_t overflow_maj;
+ static DECLARE_BITMAP(overflow_map, IB_UVERBS_MAX_DEVICES);
+@@ -965,7 +997,11 @@ static void ib_uverbs_remove_one(struct ib_device *device)
+ kfree(uverbs_dev);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
+ static char *uverbs_devnode(struct device *dev, umode_t *mode)
++#else
++static char *uverbs_devnode(struct device *dev, mode_t *mode)
++#endif
+ {
+ if (mode)
+ *mode = 0666;
+@@ -992,7 +1028,11 @@ static int __init ib_uverbs_init(void)
+
+ uverbs_class->devnode = uverbs_devnode;
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
+ ret = class_create_file(uverbs_class, &class_attr_abi_version.attr);
++#else
++ ret = class_create_file(uverbs_class, &class_attr_abi_version);
++#endif
+ if (ret) {
+ printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n");
+ goto out_class;
+++ /dev/null
-Subject: [PATCH] Backports for OFED-3.18
-
-Slightly modified OFED-3.12-1 backports for the infininband/core
-to apply to linux-3.18
-
-Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
----
- drivers/infiniband/core/addr.c | 105 ++++++++++++++++++++++++++++++++++
-
-diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/addr.c
-+++ b/drivers/infiniband/core/addr.c
-@@ -192,28 +192,45 @@ static void queue_req(struct addr_req *req)
- mutex_unlock(&lock);
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
- static int dst_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *dev_addr, void *daddr)
-+#else
-+static int dst_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *addr)
-+#endif
- {
- struct neighbour *n;
- int ret;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
- n = dst_neigh_lookup(dst, daddr);
-+#endif
-
- rcu_read_lock();
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
-+ n = dst_get_neighbour(dst);
-+#endif
- if (!n || !(n->nud_state & NUD_VALID)) {
- if (n)
- neigh_event_send(n, NULL);
- ret = -ENODATA;
- } else {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
- ret = rdma_copy_addr(dev_addr, dst->dev, n->ha);
-+#else
-+ ret = rdma_copy_addr(addr, dst->dev, n->ha);
-+#endif
- }
- rcu_read_unlock();
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
- if (n)
- neigh_release(n);
-+#endif
-
- return ret;
- }
-+#endif
-
- static int addr4_resolve(struct sockaddr_in *src_in,
- struct sockaddr_in *dst_in,
-@@ -222,9 +239,15 @@ static int addr4_resolve(struct sockaddr_in *src_in,
- __be32 src_ip = src_in->sin_addr.s_addr;
- __be32 dst_ip = dst_in->sin_addr.s_addr;
- struct rtable *rt;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
- struct flowi4 fl4;
-+#else
-+ struct flowi fl;
-+ struct neighbour *neigh;
-+#endif
- int ret;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
- memset(&fl4, 0, sizeof(fl4));
- fl4.daddr = dst_ip;
- fl4.saddr = src_ip;
-@@ -234,10 +257,25 @@ static int addr4_resolve(struct sockaddr_in *src_in,
- ret = PTR_ERR(rt);
- goto out;
- }
-+#else
-+ memset(&fl, 0, sizeof(fl));
-+ fl.nl_u.ip4_u.daddr = dst_ip;
-+ fl.nl_u.ip4_u.saddr = src_ip;
-+ fl.oif = addr->bound_dev_if;
-+ ret = ip_route_output_key(&init_net, &rt, &fl);
-+ if (ret)
-+ goto out;
-+#endif
- src_in->sin_family = AF_INET;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
- src_in->sin_addr.s_addr = fl4.saddr;
-
- if (rt->dst.dev->flags & IFF_LOOPBACK) {
-+#else
-+ src_in->sin_addr.s_addr = rt->rt_src;
-+
-+ if (rt->idev->dev->flags & IFF_LOOPBACK) {
-+#endif
- ret = rdma_translate_ip((struct sockaddr *)dst_in, addr, NULL);
- if (!ret)
- memcpy(addr->dst_dev_addr, addr->src_dev_addr, MAX_ADDR_LEN);
-@@ -245,12 +283,37 @@ static int addr4_resolve(struct sockaddr_in *src_in,
- }
-
- /* If the device does ARP internally, return 'done' */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
- if (rt->dst.dev->flags & IFF_NOARP) {
- ret = rdma_copy_addr(addr, rt->dst.dev, NULL);
- goto put;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
- ret = dst_fetch_ha(&rt->dst, addr, &fl4.daddr);
-+#else
-+ ret = dst_fetch_ha(&rt->dst, addr);
-+#endif
-+#else
-+ if (rt->idev->dev->flags & IFF_NOARP) {
-+ ret = rdma_copy_addr(addr, rt->idev->dev, NULL);
-+ goto put;
-+ }
-+
-+ neigh = neigh_lookup(&arp_tbl, &rt->rt_gateway, rt->idev->dev);
-+ if (!neigh || !(neigh->nud_state & NUD_VALID)) {
-+ neigh_event_send(rt->u.dst.neighbour, NULL);
-+ ret = -ENODATA;
-+ if (neigh)
-+ goto release;
-+ goto put;
-+ }
-+
-+ ret = rdma_copy_addr(addr, neigh->dev, neigh->ha);
-+release:
-+ neigh_release(neigh);
-+#endif
-+
- put:
- ip_rt_put(rt);
- out:
-@@ -262,10 +325,16 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
- struct sockaddr_in6 *dst_in,
- struct rdma_dev_addr *addr)
- {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
- struct flowi6 fl6;
-+#else
-+ struct flowi fl;
-+ struct neighbour *neigh;
-+#endif
- struct dst_entry *dst;
- int ret;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
- memset(&fl6, 0, sizeof fl6);
- fl6.daddr = dst_in->sin6_addr;
- fl6.saddr = src_in->sin6_addr;
-@@ -284,6 +353,26 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
- src_in->sin6_family = AF_INET6;
- src_in->sin6_addr = fl6.saddr;
- }
-+#else
-+ memset(&fl, 0, sizeof fl);
-+ ipv6_addr_copy(&fl.fl6_dst, &dst_in->sin6_addr);
-+ ipv6_addr_copy(&fl.fl6_src, &src_in->sin6_addr);
-+ fl.oif = addr->bound_dev_if;
-+
-+ dst = ip6_route_output(&init_net, NULL, &fl);
-+ if ((ret = dst->error))
-+ goto put;
-+
-+ if (ipv6_addr_any(&fl.fl6_src)) {
-+ ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
-+ &fl.fl6_dst, 0, &fl.fl6_src);
-+ if (ret)
-+ goto put;
-+
-+ src_in->sin6_family = AF_INET6;
-+ ipv6_addr_copy(&src_in->sin6_addr, &fl.fl6_src);
-+ }
-+#endif
-
- if (dst->dev->flags & IFF_LOOPBACK) {
- ret = rdma_translate_ip((struct sockaddr *) dst_in, addr);
-@@ -298,7 +387,23 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
- goto put;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
- ret = dst_fetch_ha(dst, addr, &fl6.daddr);
-+#else
-+ ret = dst_fetch_ha(dst, addr);
-+#endif
-+#else
-+ neigh = dst->neighbour;
-+ if (!neigh || !(neigh->nud_state & NUD_VALID)) {
-+ neigh_event_send(dst->neighbour, NULL);
-+ ret = -ENODATA;
-+ goto put;
-+ }
-+
-+ ret = rdma_copy_addr(addr, dst->dev, neigh->ha);
-+#endif
-+
- put:
- dst_release(dst);
- return ret;
-diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/cm.c
-+++ b/drivers/infiniband/core/cm.c
-@@ -381,6 +381,7 @@ static int cm_init_av_by_path(struct ib_sa_path_rec *path, struct cm_av *av)
-
- static int cm_alloc_id(struct cm_id_private *cm_id_priv)
- {
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
- unsigned long flags;
- int id;
- static int next_id;
-@@ -397,6 +398,24 @@ static int cm_alloc_id(struct cm_id_private *cm_id_priv)
-
- cm_id_priv->id.local_id = (__force __be32)id ^ cm.random_id_operand;
- return id < 0 ? id : 0;
-+#else
-+ unsigned long flags;
-+ int ret, id;
-+ static int next_id;
-+
-+ do {
-+ spin_lock_irqsave(&cm.lock, flags);
-+ ret = idr_get_new_above(&cm.local_id_table, cm_id_priv,
-+ next_id, &id);
-+ if (!ret)
-+ next_id = ((unsigned) id + 1) & MAX_IDR_MASK;
-+
-+ spin_unlock_irqrestore(&cm.lock, flags);
-+ } while( (ret == -EAGAIN) && idr_pre_get(&cm.local_id_table, GFP_KERNEL) );
-+
-+ cm_id_priv->id.local_id = (__force __be32)id ^ cm.random_id_operand;
-+ return ret;
-+#endif
- }
-
- static void cm_free_id(__be32 local_id)
-@@ -3660,7 +3679,11 @@ static struct kobj_type cm_port_obj_type = {
- .release = cm_release_port_obj
- };
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
- static char *cm_devnode(struct device *dev, umode_t *mode)
-+#else
-+static char *cm_devnode(struct device *dev, mode_t *mode)
-+#endif
- {
- if (mode)
- *mode = 0666;
-diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/fmr_pool.c
-+++ b/drivers/infiniband/core/fmr_pool.c
-@@ -118,13 +118,20 @@ static inline struct ib_pool_fmr *ib_fmr_cache_lookup(struct ib_fmr_pool *pool,
- {
- struct hlist_head *bucket;
- struct ib_pool_fmr *fmr;
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+ struct hlist_node *pos;
-+#endif
-
- if (!pool->cache_bucket)
- return NULL;
-
- bucket = pool->cache_bucket + ib_fmr_hash(*page_list);
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+ hlist_for_each_entry(fmr, pos, bucket, cache_node)
-+#else
- hlist_for_each_entry(fmr, bucket, cache_node)
-+#endif
- if (io_virtual_address == fmr->io_virtual_address &&
- page_list_len == fmr->page_list_len &&
- !memcmp(page_list, fmr->page_list,
-diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/netlink.c
-+++ b/drivers/infiniband/core/netlink.c
-@@ -30,6 +30,9 @@
- * SOFTWARE.
- */
-
-+#ifdef pr_fmt
-+#undef pr_fmt
-+#endif
- #define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
-
- #include <linux/export.h>
-@@ -152,11 +155,19 @@ static int ibnl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
- return -EINVAL;
-
- {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0) || defined(CONFIG_COMPAT_NETLINK_3_7)
- struct netlink_dump_control c = {
- .dump = client->cb_table[op].dump,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0) || defined(CONFIG_COMPAT_NETLINK_3_7)
- .module = client->cb_table[op].module,
-+#endif
- };
- return netlink_dump_start(nls, skb, nlh, &c);
-+#else
-+ return netlink_dump_start(nls, skb, nlh,
-+ client->cb_table[op].dump,
-+ NULL, 0);
-+#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) */
- }
- }
- }
-@@ -174,11 +185,20 @@ static void ibnl_rcv(struct sk_buff *skb)
-
- int __init ibnl_init(void)
- {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
- struct netlink_kernel_cfg cfg = {
- .input = ibnl_rcv,
- };
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- nls = netlink_kernel_create(&init_net, NETLINK_RDMA, &cfg);
-+#else
-+ nls = netlink_kernel_create(&init_net, NETLINK_RDMA, THIS_MODULE, &cfg);
-+#endif
-+#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
-+ nls = netlink_kernel_create(&init_net, NETLINK_RDMA, 0, ibnl_rcv,
-+ NULL, THIS_MODULE);
-+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0) */
- if (!nls) {
- pr_warn("Failed to create netlink socket\n");
- return -ENOMEM;
-diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/umem.c
-+++ b/drivers/infiniband/core/umem.c
-@@ -137,7 +137,11 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
-
- down_write(¤t->mm->mmap_sem);
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
- locked = npages + current->mm->pinned_vm;
-+#else
-+ locked = npages + current->mm->locked_vm;
-+#endif
- lock_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
-
- if ((locked > lock_limit) && !capable(CAP_IPC_LOCK)) {
-@@ -207,7 +211,11 @@ out:
- __ib_umem_release(context->device, umem, 0);
- kfree(umem);
- } else
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
- current->mm->pinned_vm = locked;
-+#else
-+ current->mm->locked_vm = locked;
-+#endif
-
- up_write(¤t->mm->mmap_sem);
- if (vma_list)
-@@ -223,7 +231,11 @@ static void ib_umem_account(struct work_struct *work)
- struct ib_umem *umem = container_of(work, struct ib_umem, work);
-
- down_write(&umem->mm->mmap_sem);
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
- umem->mm->pinned_vm -= umem->diff;
-+#else
-+ umem->mm->locked_vm -= umem->diff;
-+#endif
- up_write(&umem->mm->mmap_sem);
- mmput(umem->mm);
- kfree(umem);
-@@ -269,7 +281,11 @@ void ib_umem_release(struct ib_umem *umem)
- } else
- down_write(&mm->mmap_sem);
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
- mm->pinned_vm -= diff;
-+#else
-+ mm->locked_vm -= diff;
-+#endif
- up_write(&mm->mmap_sem);
- mmput(mm);
- out:
-diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/sa_query.c
-+++ b/drivers/infiniband/core/sa_query.c
-@@ -611,10 +611,13 @@ static void init_mad(struct ib_sa_mad *mad, struct ib_mad_agent *agent)
-
- static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask)
- {
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
- bool preload = !!(gfp_mask & __GFP_WAIT);
-+#endif
- unsigned long flags;
- int ret, id;
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
- if (preload)
- idr_preload(gfp_mask);
- spin_lock_irqsave(&idr_lock, flags);
-@@ -626,6 +629,18 @@ static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask)
- idr_preload_end();
- if (id < 0)
- return id;
-+#else
-+retry:
-+ if (!idr_pre_get(&query_idr, gfp_mask))
-+ return -ENOMEM;
-+ spin_lock_irqsave(&idr_lock, flags);
-+ ret = idr_get_new(&query_idr, query, &id);
-+ spin_unlock_irqrestore(&idr_lock, flags);
-+ if (ret == -EAGAIN)
-+ goto retry;
-+ if (ret)
-+ return ret;
-+#endif
-
- query->mad_buf->timeout_ms = timeout_ms;
- query->mad_buf->context[0] = query;
-diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/ucm.c
-+++ b/drivers/infiniband/core/ucm.c
-@@ -176,6 +176,9 @@ static void ib_ucm_cleanup_events(struct ib_ucm_context *ctx)
- static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
- {
- struct ib_ucm_context *ctx;
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
-+ int result;
-+#endif
-
- ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
- if (!ctx)
-@@ -186,11 +189,26 @@ static struct ib_ucm_context *ib_ucm_ctx_alloc(struct ib_ucm_file *file)
- ctx->file = file;
- INIT_LIST_HEAD(&ctx->events);
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
- mutex_lock(&ctx_id_mutex);
- ctx->id = idr_alloc(&ctx_id_table, ctx, 0, 0, GFP_KERNEL);
- mutex_unlock(&ctx_id_mutex);
- if (ctx->id < 0)
- goto error;
-+#else
-+ do {
-+ result = idr_pre_get(&ctx_id_table, GFP_KERNEL);
-+ if (!result)
-+ goto error;
-+
-+ mutex_lock(&ctx_id_mutex);
-+ result = idr_get_new(&ctx_id_table, ctx, &ctx->id);
-+ mutex_unlock(&ctx_id_mutex);
-+ } while (result == -EAGAIN);
-+
-+ if (result)
-+ goto error;
-+#endif
-
- list_add_tail(&ctx->file_list, &file->ctxs);
- return ctx;
-@@ -1321,8 +1339,16 @@ static void ib_ucm_remove_one(struct ib_device *device)
- device_unregister(&ucm_dev->dev);
- }
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
- static CLASS_ATTR_STRING(abi_version, S_IRUGO,
- __stringify(IB_USER_CM_ABI_VERSION));
-+#else
-+static ssize_t show_abi_version(struct class *class, char *buf)
-+{
-+ return sprintf(buf, "%d\n", IB_USER_CM_ABI_VERSION);
-+}
-+static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
-+#endif
-
- static int __init ib_ucm_init(void)
- {
-@@ -1335,7 +1361,11 @@ static int __init ib_ucm_init(void)
- goto error1;
- }
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
- ret = class_create_file(&cm_class, &class_attr_abi_version.attr);
-+#else
-+ ret = class_create_file(&cm_class, &class_attr_abi_version);
-+#endif
- if (ret) {
- printk(KERN_ERR "ucm: couldn't create abi_version attribute\n");
- goto error2;
-@@ -1349,7 +1379,11 @@ static int __init ib_ucm_init(void)
- return 0;
-
- error3:
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
- class_remove_file(&cm_class, &class_attr_abi_version.attr);
-+#else
-+ class_remove_file(&cm_class, &class_attr_abi_version);
-+#endif
- error2:
- unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
- error1:
-@@ -1359,7 +1393,11 @@ error1:
- static void __exit ib_ucm_cleanup(void)
- {
- ib_unregister_client(&ucm_client);
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
- class_remove_file(&cm_class, &class_attr_abi_version.attr);
-+#else
-+ class_remove_file(&cm_class, &class_attr_abi_version);
-+#endif
- unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
- if (overflow_maj)
- unregister_chrdev_region(overflow_maj, IB_UCM_MAX_DEVICES);
-diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/ucma.c
-+++ b/drivers/infiniband/core/ucma.c
-@@ -56,6 +56,7 @@ MODULE_LICENSE("Dual BSD/GPL");
-
- static unsigned int max_backlog = 1024;
-
-+#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
- static struct ctl_table_header *ucma_ctl_table_hdr;
- static ctl_table ucma_ctl_table[] = {
- {
-@@ -67,6 +68,14 @@ static ctl_table ucma_ctl_table[] = {
- },
- { }
- };
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
-+static struct ctl_path ucma_ctl_path[] = {
-+ { .procname = "net" },
-+ { .procname = "rdma_ucm" },
-+ { }
-+};
-+#endif
-+#endif
-
- struct ucma_file {
- struct mutex mut;
-@@ -147,6 +156,9 @@ static void ucma_put_ctx(struct ucma_context *ctx)
- static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
- {
- struct ucma_context *ctx;
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
-+ int ret;
-+#endif
-
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
- if (!ctx)
-@@ -157,11 +169,26 @@ static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
- INIT_LIST_HEAD(&ctx->mc_list);
- ctx->file = file;
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
-+ do {
-+ ret = idr_pre_get(&ctx_idr, GFP_KERNEL);
-+ if (!ret)
-+ goto error;
-+
-+ mutex_lock(&mut);
-+ ret = idr_get_new(&ctx_idr, ctx, &ctx->id);
-+ mutex_unlock(&mut);
-+ } while (ret == -EAGAIN);
-+
-+ if (ret)
-+ goto error;
-+#else
- mutex_lock(&mut);
- ctx->id = idr_alloc(&ctx_idr, ctx, 0, 0, GFP_KERNEL);
- mutex_unlock(&mut);
- if (ctx->id < 0)
- goto error;
-+#endif
-
- list_add_tail(&ctx->list, &file->ctx_list);
- return ctx;
-@@ -174,16 +201,34 @@ error:
- static struct ucma_multicast* ucma_alloc_multicast(struct ucma_context *ctx)
- {
- struct ucma_multicast *mc;
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
-+ int ret;
-+#endif
-
- mc = kzalloc(sizeof(*mc), GFP_KERNEL);
- if (!mc)
- return NULL;
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0))
-+ do {
-+ ret = idr_pre_get(&multicast_idr, GFP_KERNEL);
-+ if (!ret)
-+ goto error;
-+
-+ mutex_lock(&mut);
-+ ret = idr_get_new(&multicast_idr, mc, &mc->id);
-+ mutex_unlock(&mut);
-+ } while (ret == -EAGAIN);
-+
-+ if (ret)
-+ goto error;
-+#else
- mutex_lock(&mut);
- mc->id = idr_alloc(&multicast_idr, mc, 0, 0, GFP_KERNEL);
- mutex_unlock(&mut);
- if (mc->id < 0)
- goto error;
-+#endif
-
- mc->ctx = ctx;
- list_add_tail(&mc->list, &ctx->mc_list);
-@@ -1408,7 +1453,11 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
- struct rdma_ucm_migrate_id cmd;
- struct rdma_ucm_migrate_resp resp;
- struct ucma_context *ctx;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- struct fd f;
-+#else
-+ struct file *filp;
-+#endif
- struct ucma_file *cur_file;
- int ret = 0;
-
-@@ -1416,12 +1465,21 @@ static ssize_t ucma_migrate_id(struct ucma_file *new_file,
- return -EFAULT;
-
- /* Get current fd to protect against it being closed */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- f = fdget(cmd.fd);
- if (!f.file)
-+#else
-+ filp = fget(cmd.fd);
-+ if (!filp)
-+#endif
- return -ENOENT;
-
- /* Validate current fd and prevent destruction of id. */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- ctx = ucma_get_ctx(f.file->private_data, cmd.id);
-+#else
-+ ctx = ucma_get_ctx(filp->private_data, cmd.id);
-+#endif
- if (IS_ERR(ctx)) {
- ret = PTR_ERR(ctx);
- goto file_put;
-@@ -1455,7 +1513,11 @@ response:
-
- ucma_put_ctx(ctx);
- file_put:
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- fdput(f);
-+#else
-+ fput(filp);
-+#endif
- return ret;
- }
-
-@@ -1616,15 +1678,23 @@ static int __init ucma_init(void)
- goto err1;
- }
-
-+#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
- ucma_ctl_table_hdr = register_net_sysctl(&init_net, "net/rdma_ucm", ucma_ctl_table);
-+#else
-+ ucma_ctl_table_hdr = register_sysctl_paths(ucma_ctl_path, ucma_ctl_table);
-+#endif
- if (!ucma_ctl_table_hdr) {
- printk(KERN_ERR "rdma_ucm: couldn't register sysctl paths\n");
- ret = -ENOMEM;
- goto err2;
- }
-+#endif
- return 0;
-+#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
- err2:
- device_remove_file(ucma_misc.this_device, &dev_attr_abi_version);
-+#endif
- err1:
- misc_deregister(&ucma_misc);
- return ret;
-@@ -1632,7 +1702,13 @@ err1:
-
- static void __exit ucma_cleanup(void)
- {
-+#ifndef CONFIG_SYSCTL_SYSCALL_CHECK
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)
- unregister_net_sysctl_table(ucma_ctl_table_hdr);
-+#else
-+ unregister_sysctl_table(ucma_ctl_table_hdr);
-+#endif
-+#endif
- device_remove_file(ucma_misc.this_device, &dev_attr_abi_version);
- misc_deregister(&ucma_misc);
- idr_destroy(&ctx_idr);
-diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/user_mad.c
-+++ b/drivers/infiniband/core/user_mad.c
-@@ -969,8 +969,16 @@ static ssize_t show_port(struct device *dev, struct device_attribute *attr,
- }
- static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
- static CLASS_ATTR_STRING(abi_version, S_IRUGO,
- __stringify(IB_USER_MAD_ABI_VERSION));
-+#else
-+static ssize_t show_abi_version(struct class *class, char *buf)
-+{
-+ return sprintf(buf, "%d\n", IB_USER_MAD_ABI_VERSION);
-+}
-+static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
-+#endif
-
- static dev_t overflow_maj;
- static DECLARE_BITMAP(overflow_map, IB_UMAD_MAX_PORTS);
-@@ -1175,7 +1183,11 @@ static void ib_umad_remove_one(struct ib_device *device)
- kref_put(&umad_dev->ref, ib_umad_release_dev);
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
- static char *umad_devnode(struct device *dev, umode_t *mode)
-+#else
-+static char *umad_devnode(struct device *dev, mode_t *mode)
-+#endif
- {
- return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
- }
-@@ -1200,7 +1212,11 @@ static int __init ib_umad_init(void)
-
- umad_class->devnode = umad_devnode;
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
- ret = class_create_file(umad_class, &class_attr_abi_version.attr);
-+#else
-+ ret = class_create_file(umad_class, &class_attr_abi_version);
-+#endif
- if (ret) {
- printk(KERN_ERR "user_mad: couldn't create abi_version attribute\n");
- goto out_class;
-diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/uverbs_cmd.c
-+++ b/drivers/infiniband/core/uverbs_cmd.c
-@@ -128,6 +128,7 @@ static int idr_add_uobj(struct idr *idr, struct ib_uobject *uobj)
- {
- int ret;
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
- idr_preload(GFP_KERNEL);
- spin_lock(&ib_uverbs_idr_lock);
-
-@@ -139,6 +140,20 @@ static int idr_add_uobj(struct idr *idr, struct ib_uobject *uobj)
- idr_preload_end();
-
- return ret < 0 ? ret : 0;
-+#else
-+retry:
-+ if (!idr_pre_get(idr, GFP_KERNEL))
-+ return -ENOMEM;
-+
-+ spin_lock(&ib_uverbs_idr_lock);
-+ ret = idr_get_new(idr, uobj, &uobj->id);
-+ spin_unlock(&ib_uverbs_idr_lock);
-+
-+ if (ret == -EAGAIN)
-+ goto retry;
-+
-+ return ret;
-+#endif
- }
-
- void idr_remove_uobj(struct idr *idr, struct ib_uobject *uobj)
-@@ -338,7 +353,11 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file,
-
- resp.num_comp_vectors = file->device->num_comp_vectors;
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
- ret = get_unused_fd_flags(O_CLOEXEC);
-+#else
-+ ret = get_unused_fd();
-+#endif
- if (ret < 0)
- goto err_free;
- resp.async_fd = ret;
-@@ -709,7 +728,11 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
- struct ib_udata udata;
- struct ib_uxrcd_object *obj;
- struct ib_xrcd *xrcd = NULL;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- struct fd f = {NULL, 0};
-+#else
-+ struct file *f = NULL;
-+#endif
- struct inode *inode = NULL;
- int ret = 0;
- int new_xrcd = 0;
-@@ -728,6 +751,7 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
-
- if (cmd.fd != -1) {
- /* search for file descriptor */
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- f = fdget(cmd.fd);
- if (!f.file) {
- ret = -EBADF;
-@@ -735,6 +759,19 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
- }
-
- inode = file_inode(f.file);
-+#else
-+ f = fget(cmd.fd);
-+ if (!f) {
-+ ret = -EBADF;
-+ goto err_tree_mutex_unlock;
-+ }
-+
-+ inode = f->f_dentry->d_inode;
-+ if (!inode) {
-+ ret = -EBADF;
-+ goto err_tree_mutex_unlock;
-+ }
-+#endif
- xrcd = find_xrcd(file->device, inode);
- if (!xrcd && !(cmd.oflags & O_CREAT)) {
- /* no file descriptor. Need CREATE flag */
-@@ -799,8 +836,13 @@ ssize_t ib_uverbs_open_xrcd(struct ib_uverbs_file *file,
- goto err_copy;
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- if (f.file)
- fdput(f);
-+#else
-+ if (f)
-+ fput(f);
-+#endif
-
- mutex_lock(&file->mutex);
- list_add_tail(&obj->uobject.list, &file->ucontext->xrcd_list);
-@@ -829,8 +871,13 @@ err:
- put_uobj_write(&obj->uobject);
-
- err_tree_mutex_unlock:
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- if (f.file)
- fdput(f);
-+#else
-+ if (f)
-+ fput(f);
-+#endif
-
- mutex_unlock(&file->device->xrcd_tree_mutex);
-
-@@ -1188,7 +1235,11 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
- if (copy_from_user(&cmd, buf, sizeof cmd))
- return -EFAULT;
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
- ret = get_unused_fd_flags(O_CLOEXEC);
-+#else
-+ ret = get_unused_fd();
-+#endif
- if (ret < 0)
- return ret;
- resp.fd = ret;
-diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/uverbs_main.c
-+++ b/drivers/infiniband/core/uverbs_main.c
-@@ -563,6 +563,7 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
- struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd)
- {
- struct ib_uverbs_event_file *ev_file = NULL;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
- struct fd f = fdget(fd);
-
- if (!f.file)
-@@ -582,6 +583,29 @@ struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd)
- out:
- fdput(f);
- return ev_file;
-+#else
-+ struct file *filp;
-+ int fput_needed;
-+
-+ filp = fget_light(fd, &fput_needed);
-+ if (!filp)
-+ return NULL;
-+
-+ if (filp->f_op != &uverbs_event_fops)
-+ goto out;
-+
-+ ev_file = filp->private_data;
-+ if (ev_file->is_async) {
-+ ev_file = NULL;
-+ goto out;
-+ }
-+
-+ kref_get(&ev_file->ref);
-+
-+out:
-+ fput_light(filp, fput_needed);
-+ return ev_file;
-+#endif
- }
-
- static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
-@@ -759,8 +783,16 @@ static ssize_t show_dev_abi_version(struct device *device,
- }
- static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL);
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
- static CLASS_ATTR_STRING(abi_version, S_IRUGO,
- __stringify(IB_USER_VERBS_ABI_VERSION));
-+#else
-+static ssize_t show_abi_version(struct class *class, char *buf)
-+{
-+ return sprintf(buf, "%d\n", IB_USER_VERBS_ABI_VERSION);
-+}
-+static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
-+#endif
-
- static dev_t overflow_maj;
- static DECLARE_BITMAP(overflow_map, IB_UVERBS_MAX_DEVICES);
-@@ -890,7 +922,11 @@ static void ib_uverbs_remove_one(struct ib_device *device)
- kfree(uverbs_dev);
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)
- static char *uverbs_devnode(struct device *dev, umode_t *mode)
-+#else
-+static char *uverbs_devnode(struct device *dev, mode_t *mode)
-+#endif
- {
- if (mode)
- *mode = 0666;
-@@ -917,7 +953,11 @@ static int __init ib_uverbs_init(void)
-
- uverbs_class->devnode = uverbs_devnode;
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
- ret = class_create_file(uverbs_class, &class_attr_abi_version.attr);
-+#else
-+ ret = class_create_file(uverbs_class, &class_attr_abi_version);
-+#endif
- if (ret) {
- printk(KERN_ERR "user_verbs: couldn't create abi_version attribute\n");
- goto out_class;
-diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/core/cma.c
-+++ b/drivers/infiniband/core/cma.c
-@@ -2269,6 +2269,7 @@ static int cma_alloc_port(struct idr *ps, struct rdma_id_private *id_priv,
- unsigned short snum)
- {
- struct rdma_bind_list *bind_list;
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0))
- int ret;
-
- bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL);
-@@ -2286,6 +2287,35 @@ static int cma_alloc_port(struct idr *ps, struct rdma_id_private *id_priv,
- err:
- kfree(bind_list);
- return ret == -ENOSPC ? -EADDRNOTAVAIL : ret;
-+#else
-+ int port, ret;
-+
-+ bind_list = kzalloc(sizeof *bind_list, GFP_KERNEL);
-+ if (!bind_list)
-+ return -ENOMEM;
-+
-+ do {
-+ ret = idr_get_new_above(ps, bind_list, snum, &port);
-+ } while ((ret == -EAGAIN) && idr_pre_get(ps, GFP_KERNEL));
-+
-+ if (ret)
-+ goto err1;
-+
-+ if (port != snum) {
-+ ret = -EADDRNOTAVAIL;
-+ goto err2;
-+ }
-+
-+ bind_list->ps = ps;
-+ bind_list->port = (unsigned short) port;
-+ cma_bind_port(bind_list, id_priv);
-+ return 0;
-+err2:
-+ idr_remove(ps, port);
-+err1:
-+ kfree(bind_list);
-+ return ret;
-+#endif
- }
-
- static int cma_alloc_any_port(struct idr *ps, struct rdma_id_private *id_priv)
-@@ -2330,9 +2360,16 @@ static int cma_check_port(struct rdma_bind_list *bind_list,
- {
- struct rdma_id_private *cur_id;
- struct sockaddr *addr, *cur_addr;
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+ struct hlist_node *node;
-+#endif
-
- addr = cma_src_addr(id_priv);
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+ hlist_for_each_entry(cur_id, node, &bind_list->owners, node) {
-+#else
- hlist_for_each_entry(cur_id, &bind_list->owners, node) {
-+#endif
- if (id_priv == cur_id)
- continue;
-
-@@ -3412,9 +3449,15 @@ static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id
- }
-
- static int cma_netdev_callback(struct notifier_block *self, unsigned long event,
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
- void *ptr)
- {
- struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
-+#else
-+ void *ctx)
-+{
-+ struct net_device *ndev = (struct net_device *)ctx;
-+#endif
- struct cma_device *cma_dev;
- struct rdma_id_private *id_priv;
- int ret = NOTIFY_DONE;
-diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
-index d570030..d3918be 100644
---- a/drivers/infiniband/core/cma.c
-+++ b/drivers/infiniband/core/cma.c
-@@ -1866,6 +1866,7 @@ static int cma_resolve_iw_route(struct rdma_id_private *id_priv, int timeout_ms)
-
- static int iboe_tos_to_sl(struct net_device *ndev, int tos)
- {
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
- int prio;
- struct net_device *dev;
-
-@@ -1881,6 +1882,7 @@ static int iboe_tos_to_sl(struct net_device *ndev, int tos)
- return (vlan_dev_get_egress_qos_mask(ndev, prio) &
- VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
- #endif
-+#endif
- return 0;
- }
--- /dev/null
+From: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
+Subject: [PATCH] BACKPORT: RDMA/nes
+
+Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
+---
+ drivers/infiniband/hw/nes/nes.c | 4 ++
+ drivers/infiniband/hw/nes/nes_cm.c | 14 +++++-
+ drivers/infiniband/hw/nes/nes_hw.c | 38 ++++++++++++--
+ drivers/infiniband/hw/nes/nes_hw.h | 6 ++
+ drivers/infiniband/hw/nes/nes_nic.c | 96 ++++++++++++++++++++++++++++++--
+ drivers/infiniband/hw/nes/nes_verbs.c | 5 ++
+ 6 files changed, 152 insertions(+), 11 deletions(-)
+
+diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/hw/nes/nes.c
++++ b/drivers/infiniband/hw/nes/nes.c
+@@ -155,7 +155,11 @@ static int nes_inetaddr_event(struct notifier_block *notifier,
+ nesdev, nesdev->netdev[0]->name);
+ netdev = nesdev->netdev[0];
+ nesvnic = netdev_priv(netdev);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
+ upper_dev = netdev_master_upper_dev_get(netdev);
++#else
++ upper_dev = netdev->master;
++#endif
+ is_bonded = netif_is_bond_slave(netdev) &&
+ (upper_dev == event_netdev);
+ if ((netdev == event_netdev) || is_bonded) {
+diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/hw/nes/nes_cm.c
++++ b/drivers/infiniband/hw/nes/nes_cm.c
+@@ -1495,16 +1495,28 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi
+ int rc = arpindex;
+ struct net_device *netdev;
+ struct nes_adapter *nesadapter = nesvnic->nesdev->nesadapter;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
++ struct flowi fl;
+
++ memset(&fl, 0, sizeof fl);
++ fl.nl_u.ip4_u.daddr = htonl(dst_ip);
++ if (ip_route_output_key(&init_net, &rt, &fl)) {
++#else
+ rt = ip_route_output(&init_net, htonl(dst_ip), 0, 0, 0);
+ if (IS_ERR(rt)) {
++#endif
+ printk(KERN_ERR "%s: ip_route_output_key failed for 0x%08X\n",
+ __func__, dst_ip);
+ return rc;
+ }
+
+- if (netif_is_bond_slave(nesvnic->netdev))
++ if (netif_is_bond_slave(nesvnic->netdev)) {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
+ netdev = netdev_master_upper_dev_get(nesvnic->netdev);
++#else
++ netdev = nesvnic->netdev->master;
++#endif
++ }
+ else
+ netdev = nesvnic->netdev;
+
+diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/hw/nes/nes_hw.c
++++ b/drivers/infiniband/hw/nes/nes_hw.c
+@@ -1003,9 +1003,14 @@ int nes_init_cqp(struct nes_device *nesdev)
+ (sizeof(struct nes_hw_aeqe) * nesadapter->max_qp) +
+ sizeof(struct nes_hw_cqp_qp_context);
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
+ nesdev->cqp_vbase = pci_zalloc_consistent(nesdev->pcidev,
+ nesdev->cqp_mem_size,
+ &nesdev->cqp_pbase);
++#else
++ nesdev->cqp_vbase = pci_alloc_consistent(nesdev->pcidev, nesdev->cqp_mem_size,
++ &nesdev->cqp_pbase);
++#endif
+ if (!nesdev->cqp_vbase) {
+ nes_debug(NES_DBG_INIT, "Unable to allocate memory for host descriptor rings\n");
+ return -ENOMEM;
+@@ -1691,9 +1696,14 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
+ (NES_NIC_WQ_SIZE * 2 * sizeof(struct nes_hw_nic_cqe)) +
+ sizeof(struct nes_hw_nic_qp_context);
+
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
+ nesvnic->nic_vbase = pci_zalloc_consistent(nesdev->pcidev,
+ nesvnic->nic_mem_size,
+ &nesvnic->nic_pbase);
++#else
++ nesvnic->nic_vbase = pci_alloc_consistent(nesdev->pcidev, nesvnic->nic_mem_size,
++ &nesvnic->nic_pbase);
++#endif
+ if (!nesvnic->nic_vbase) {
+ nes_debug(NES_DBG_INIT, "Unable to allocate memory for NIC host descriptor rings\n");
+ return -ENOMEM;
+@@ -2909,7 +2919,11 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
+ if ((cqe_errv &
+ (NES_NIC_ERRV_BITS_IPV4_CSUM_ERR | NES_NIC_ERRV_BITS_TCPUDP_CSUM_ERR |
+ NES_NIC_ERRV_BITS_IPH_ERR | NES_NIC_ERRV_BITS_WQE_OVERRUN)) == 0) {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
++ if (nesvnic->rx_checksum_disabled == 0)
++#else
+ if (nesvnic->netdev->features & NETIF_F_RXCSUM)
++#endif
+ rx_skb->ip_summed = CHECKSUM_UNNECESSARY;
+ } else
+ nes_debug(NES_DBG_CQ, "%s: unsuccessfully checksummed TCP or UDP packet."
+@@ -2920,11 +2934,12 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
+ if ((cqe_errv &
+ (NES_NIC_ERRV_BITS_IPV4_CSUM_ERR | NES_NIC_ERRV_BITS_IPH_ERR |
+ NES_NIC_ERRV_BITS_WQE_OVERRUN)) == 0) {
+- if (nesvnic->netdev->features & NETIF_F_RXCSUM) {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
++ if (nesvnic->rx_checksum_disabled == 0)
++#else
++ if (nesvnic->netdev->features & NETIF_F_RXCSUM)
++#endif
+ rx_skb->ip_summed = CHECKSUM_UNNECESSARY;
+- /* nes_debug(NES_DBG_CQ, "%s: Reporting successfully checksummed IPv4 packet.\n",
+- nesvnic->netdev->name); */
+- }
+ } else
+ nes_debug(NES_DBG_CQ, "%s: unsuccessfully checksummed TCP or UDP packet."
+ " errv = 0x%X, pkt_type = 0x%X.\n",
+@@ -2948,7 +2963,22 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
+ nes_debug(NES_DBG_CQ, "%s: Reporting stripped VLAN packet. Tag = 0x%04X\n",
+ nesvnic->netdev->name, vlan_tag);
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
++ if (nesvnic->vlan_grp != NULL) {
++ if (nes_use_lro)
++ lro_vlan_hwaccel_receive_skb(&nesvnic->lro_mgr, rx_skb,
++ nesvnic->vlan_grp, vlan_tag, NULL);
++ else
++ vlan_hwaccel_receive_skb(rx_skb, nesvnic->vlan_grp, vlan_tag);
++ goto skip_rx_indicate0;
++ }
++#endif
++
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
++ __vlan_hwaccel_put_tag(rx_skb, vlan_tag);
++#else
+ __vlan_hwaccel_put_tag(rx_skb, htons(ETH_P_8021Q), vlan_tag);
++#endif
+ }
+ if (nes_use_lro)
+ lro_receive_skb(&nesvnic->lro_mgr, rx_skb, NULL);
+diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/hw/nes/nes_hw.h
++++ b/drivers/infiniband/hw/nes/nes_hw.h
+@@ -1269,6 +1269,12 @@ struct nes_vnic {
+ u8 next_qp_nic_index;
+ u8 of_device_registered;
+ u8 rdma_enabled;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
++ struct vlan_group *vlan_grp;
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
++ u8 rx_checksum_disabled;
++#endif
+ u32 lro_max_aggr;
+ struct net_lro_mgr lro_mgr;
+ struct net_lro_desc lro_desc[NES_MAX_LRO_DESCRIPTORS];
+diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/hw/nes/nes_nic.c
++++ b/drivers/infiniband/hw/nes/nes_nic.c
+@@ -904,16 +904,24 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
+ if (!mc_all_on) {
+ char *addrs;
+ int i;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
+ struct netdev_hw_addr *ha;
+-
++#else
++ struct dev_mc_list *mcaddr;
++#endif
+ addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
+ if (!addrs) {
+ set_allmulti(nesdev, nic_active_bit);
+ goto unlock;
+ }
+ i = 0;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
+ netdev_for_each_mc_addr(ha, netdev)
+ memcpy(get_addr(addrs, i++), ha->addr, ETH_ALEN);
++#else
++ netdev_for_each_mc_addr(mcaddr, netdev)
++ memcpy(get_addr(addrs, i++), mcaddr->dmi_addr, ETH_ALEN);
++#endif
+
+ perfect_filter_register_address = NES_IDX_PERFECT_FILTER_LOW +
+ pft_entries_preallocated * 0x8;
+@@ -1572,6 +1580,34 @@ static int nes_netdev_set_settings(struct net_device *netdev, struct ethtool_cmd
+ return 0;
+ }
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
++/**
++ * nes_netdev_get_rx_csum
++ */
++static u32 nes_netdev_get_rx_csum (struct net_device *netdev)
++{
++ struct nes_vnic *nesvnic = netdev_priv(netdev);
++
++ if (nesvnic->rx_checksum_disabled)
++ return 0;
++ else
++ return 1;
++}
++
++/**
++ * nes_netdev_set_rc_csum
++ */
++static int nes_netdev_set_rx_csum(struct net_device *netdev, u32 enable)
++{
++ struct nes_vnic *nesvnic = netdev_priv(netdev);
++
++ if (enable)
++ nesvnic->rx_checksum_disabled = 0;
++ else
++ nesvnic->rx_checksum_disabled = 1;
++ return 0;
++}
++#endif
+
+ static const struct ethtool_ops nes_ethtool_ops = {
+ .get_link = ethtool_op_get_link,
+@@ -1585,8 +1621,46 @@ static const struct ethtool_ops nes_ethtool_ops = {
+ .set_coalesce = nes_netdev_set_coalesce,
+ .get_pauseparam = nes_netdev_get_pauseparam,
+ .set_pauseparam = nes_netdev_set_pauseparam,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
++ .get_tx_csum = ethtool_op_get_tx_csum,
++ .set_tx_csum = ethtool_op_set_tx_csum,
++ .get_rx_csum = nes_netdev_get_rx_csum,
++ .set_rx_csum = nes_netdev_set_rx_csum,
++ .get_sg = ethtool_op_get_sg,
++ .set_sg = ethtool_op_set_sg,
++ .get_tso = ethtool_op_get_tso,
++ .set_tso = ethtool_op_set_tso,
++ .get_flags = ethtool_op_get_flags,
++ .set_flags = ethtool_op_set_flags
++#endif
+ };
+
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
++static void nes_netdev_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
++{
++ struct nes_vnic *nesvnic = netdev_priv(netdev);
++ struct nes_device *nesdev = nesvnic->nesdev;
++ struct nes_adapter *nesadapter = nesdev->nesadapter;
++ u32 u32temp;
++ unsigned long flags;
++
++ spin_lock_irqsave(&nesadapter->phy_lock, flags);
++ nesvnic->vlan_grp = grp;
++
++ nes_debug(NES_DBG_NETDEV, "%s: %s\n", __func__, netdev->name);
++
++ /* Enable/Disable VLAN Stripping */
++ u32temp = nes_read_indexed(nesdev, NES_IDX_PCIX_DIAG);
++ if (grp)
++ u32temp &= 0xfdffffff;
++ else
++ u32temp |= 0x02000000;
++
++ nes_write_indexed(nesdev, NES_IDX_PCIX_DIAG, u32temp);
++ spin_unlock_irqrestore(&nesadapter->phy_lock, flags);
++}
++#endif
++
+ static void nes_vlan_mode(struct net_device *netdev, struct nes_device *nesdev, netdev_features_t features)
+ {
+ struct nes_adapter *nesadapter = nesdev->nesadapter;
+@@ -1608,6 +1682,7 @@ static void nes_vlan_mode(struct net_device *netdev, struct nes_device *nesdev,
+ spin_unlock_irqrestore(&nesadapter->phy_lock, flags);
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+ static netdev_features_t nes_fix_features(struct net_device *netdev, netdev_features_t features)
+ {
+ /*
+@@ -1633,6 +1708,7 @@ static int nes_set_features(struct net_device *netdev, netdev_features_t feature
+
+ return 0;
+ }
++#endif
+
+ static const struct net_device_ops nes_netdev_ops = {
+ .ndo_open = nes_netdev_open,
+@@ -1644,8 +1720,13 @@ static const struct net_device_ops nes_netdev_ops = {
+ .ndo_set_rx_mode = nes_netdev_set_multicast_list,
+ .ndo_change_mtu = nes_netdev_change_mtu,
+ .ndo_validate_addr = eth_validate_addr,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
+ .ndo_fix_features = nes_fix_features,
+ .ndo_set_features = nes_set_features,
++#endif
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
++ .ndo_vlan_rx_register = nes_netdev_vlan_rx_register,
++#endif
+ };
+
+ /**
+@@ -1706,12 +1787,15 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
+ netdev->dev_addr[4] = (u8)(u64temp>>8);
+ netdev->dev_addr[5] = (u8)u64temp;
+
+- netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX;
+- if ((nesvnic->logical_port < 2) || (nesdev->nesadapter->hw_rev != NE020_REV))
+- netdev->hw_features |= NETIF_F_TSO;
++ netdev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX;
++
++ if ((nesvnic->logical_port < 2) || (nesdev->nesadapter->hw_rev != NE020_REV))
++ netdev->features |= NETIF_F_TSO;
+
+- netdev->features = netdev->hw_features | NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_TX;
+- netdev->hw_features |= NETIF_F_LRO;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
++ netdev->hw_features |= netdev->features | NETIF_F_LRO;
++#endif
++ netdev->features |= NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_TX;
+
+ nes_debug(NES_DBG_INIT, "nesvnic = %p, reported features = 0x%lX, QPid = %d,"
+ " nic_index = %d, logical_port = %d, mac_index = %d.\n",
+diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/hw/nes/nes_verbs.c
++++ b/drivers/infiniband/hw/nes/nes_verbs.c
+@@ -1616,8 +1616,13 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
+ entries, nescq->cq_mem_size, nescq->hw_cq.cq_number);
+
+ /* allocate the physical buffer space */
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
+ mem = pci_zalloc_consistent(nesdev->pcidev, nescq->cq_mem_size,
+ &nescq->hw_cq.cq_pbase);
++#else
++ mem = pci_alloc_consistent(nesdev->pcidev, nescq->cq_mem_size,
++ &nescq->hw_cq.cq_pbase);
++#endif
+ if (!mem) {
+ printk(KERN_ERR PFX "Unable to allocate pci memory for cq\n");
+ nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num);
+++ /dev/null
-Subject: [PATCH] RDMA/nes: Backports for OFED-3.18
-
-Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
----
- drivers/infiniband/hw/nes/nes.c | 4 ++
- drivers/infiniband/hw/nes/nes_cm.c | 14 +++++-
- drivers/infiniband/hw/nes/nes_hw.c | 28 +++++++++--
- drivers/infiniband/hw/nes/nes_hw.h | 6 +++
- drivers/infiniband/hw/nes/nes_nic.c | 96 ++++++++++++++++++++++++++++++++++---
- 5 files changed, 137 insertions(+), 11 deletions(-)
-
-diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/hw/nes/nes.c
-+++ b/drivers/infiniband/hw/nes/nes.c
-@@ -146,7 +146,11 @@ static int nes_inetaddr_event(struct notifier_block *notifier,
- nesdev, nesdev->netdev[0]->name);
- netdev = nesdev->netdev[0];
- nesvnic = netdev_priv(netdev);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
- upper_dev = netdev_master_upper_dev_get(netdev);
-+#else
-+ upper_dev = netdev->master;
-+#endif
- is_bonded = netif_is_bond_slave(netdev) &&
- (upper_dev == event_netdev);
- if ((netdev == event_netdev) || is_bonded) {
-diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/hw/nes/nes_cm.c
-+++ b/drivers/infiniband/hw/nes/nes_cm.c
-@@ -1331,16 +1331,28 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi
- int rc = arpindex;
- struct net_device *netdev;
- struct nes_adapter *nesadapter = nesvnic->nesdev->nesadapter;
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
-+ struct flowi fl;
-
-+ memset(&fl, 0, sizeof fl);
-+ fl.nl_u.ip4_u.daddr = htonl(dst_ip);
-+ if (ip_route_output_key(&init_net, &rt, &fl)) {
-+#else
- rt = ip_route_output(&init_net, htonl(dst_ip), 0, 0, 0);
- if (IS_ERR(rt)) {
-+#endif
- printk(KERN_ERR "%s: ip_route_output_key failed for 0x%08X\n",
- __func__, dst_ip);
- return rc;
- }
-
-- if (netif_is_bond_slave(nesvnic->netdev))
-+ if (netif_is_bond_slave(nesvnic->netdev)) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
- netdev = netdev_master_upper_dev_get(nesvnic->netdev);
-+#else
-+ netdev = nesvnic->netdev->master;
-+#endif
-+ }
- else
- netdev = nesvnic->netdev;
-
-diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/hw/nes/nes_hw.c
-+++ b/drivers/infiniband/hw/nes/nes_hw.c
-@@ -2909,7 +2909,11 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
- if ((cqe_errv &
- (NES_NIC_ERRV_BITS_IPV4_CSUM_ERR | NES_NIC_ERRV_BITS_TCPUDP_CSUM_ERR |
- NES_NIC_ERRV_BITS_IPH_ERR | NES_NIC_ERRV_BITS_WQE_OVERRUN)) == 0) {
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
-+ if (nesvnic->rx_checksum_disabled == 0)
-+#else
- if (nesvnic->netdev->features & NETIF_F_RXCSUM)
-+#endif
- rx_skb->ip_summed = CHECKSUM_UNNECESSARY;
- } else
- nes_debug(NES_DBG_CQ, "%s: unsuccessfully checksummed TCP or UDP packet."
-@@ -2920,11 +2924,12 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
- if ((cqe_errv &
- (NES_NIC_ERRV_BITS_IPV4_CSUM_ERR | NES_NIC_ERRV_BITS_IPH_ERR |
- NES_NIC_ERRV_BITS_WQE_OVERRUN)) == 0) {
-- if (nesvnic->netdev->features & NETIF_F_RXCSUM) {
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
-+ if (nesvnic->rx_checksum_disabled == 0)
-+#else
-+ if (nesvnic->netdev->features & NETIF_F_RXCSUM)
-+#endif
- rx_skb->ip_summed = CHECKSUM_UNNECESSARY;
-- /* nes_debug(NES_DBG_CQ, "%s: Reporting successfully checksummed IPv4 packet.\n",
-- nesvnic->netdev->name); */
-- }
- } else
- nes_debug(NES_DBG_CQ, "%s: unsuccessfully checksummed TCP or UDP packet."
- " errv = 0x%X, pkt_type = 0x%X.\n",
-@@ -2948,7 +2953,22 @@ void nes_nic_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *cq)
- nes_debug(NES_DBG_CQ, "%s: Reporting stripped VLAN packet. Tag = 0x%04X\n",
- nesvnic->netdev->name, vlan_tag);
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))
-+ if (nesvnic->vlan_grp != NULL) {
-+ if (nes_use_lro)
-+ lro_vlan_hwaccel_receive_skb(&nesvnic->lro_mgr, rx_skb,
-+ nesvnic->vlan_grp, vlan_tag, NULL);
-+ else
-+ vlan_hwaccel_receive_skb(rx_skb, nesvnic->vlan_grp, vlan_tag);
-+ goto skip_rx_indicate0;
-+ }
-+#endif
-+
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
-+ __vlan_hwaccel_put_tag(rx_skb, vlan_tag);
-+#else
- __vlan_hwaccel_put_tag(rx_skb, htons(ETH_P_8021Q), vlan_tag);
-+#endif
- }
- if (nes_use_lro)
- lro_receive_skb(&nesvnic->lro_mgr, rx_skb, NULL);
-diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/hw/nes/nes_hw.h
-+++ b/drivers/infiniband/hw/nes/nes_hw.h
-@@ -1269,6 +1269,12 @@ struct nes_vnic {
- u8 next_qp_nic_index;
- u8 of_device_registered;
- u8 rdma_enabled;
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
-+ struct vlan_group *vlan_grp;
-+#endif
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
-+ u8 rx_checksum_disabled;
-+#endif
- u32 lro_max_aggr;
- struct net_lro_mgr lro_mgr;
- struct net_lro_desc lro_desc[NES_MAX_LRO_DESCRIPTORS];
-diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
-index xxxxxxx..xxxxxxx xxxxxx
---- a/drivers/infiniband/hw/nes/nes_nic.c
-+++ b/drivers/infiniband/hw/nes/nes_nic.c
-@@ -904,16 +904,24 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
- if (!mc_all_on) {
- char *addrs;
- int i;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
- struct netdev_hw_addr *ha;
--
-+#else
-+ struct dev_mc_list *mcaddr;
-+#endif
- addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
- if (!addrs) {
- set_allmulti(nesdev, nic_active_bit);
- goto unlock;
- }
- i = 0;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
- netdev_for_each_mc_addr(ha, netdev)
- memcpy(get_addr(addrs, i++), ha->addr, ETH_ALEN);
-+#else
-+ netdev_for_each_mc_addr(mcaddr, netdev)
-+ memcpy(get_addr(addrs, i++), mcaddr->dmi_addr, ETH_ALEN);
-+#endif
-
- perfect_filter_register_address = NES_IDX_PERFECT_FILTER_LOW +
- pft_entries_preallocated * 0x8;
-@@ -1572,6 +1580,34 @@ static int nes_netdev_set_settings(struct net_device *netdev, struct ethtool_cmd
- return 0;
- }
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
-+/**
-+ * nes_netdev_get_rx_csum
-+ */
-+static u32 nes_netdev_get_rx_csum (struct net_device *netdev)
-+{
-+ struct nes_vnic *nesvnic = netdev_priv(netdev);
-+
-+ if (nesvnic->rx_checksum_disabled)
-+ return 0;
-+ else
-+ return 1;
-+}
-+
-+/**
-+ * nes_netdev_set_rc_csum
-+ */
-+static int nes_netdev_set_rx_csum(struct net_device *netdev, u32 enable)
-+{
-+ struct nes_vnic *nesvnic = netdev_priv(netdev);
-+
-+ if (enable)
-+ nesvnic->rx_checksum_disabled = 0;
-+ else
-+ nesvnic->rx_checksum_disabled = 1;
-+ return 0;
-+}
-+#endif
-
- static const struct ethtool_ops nes_ethtool_ops = {
- .get_link = ethtool_op_get_link,
-@@ -1585,8 +1621,46 @@ static const struct ethtool_ops nes_ethtool_ops = {
- .set_coalesce = nes_netdev_set_coalesce,
- .get_pauseparam = nes_netdev_get_pauseparam,
- .set_pauseparam = nes_netdev_set_pauseparam,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
-+ .get_tx_csum = ethtool_op_get_tx_csum,
-+ .set_tx_csum = ethtool_op_set_tx_csum,
-+ .get_rx_csum = nes_netdev_get_rx_csum,
-+ .set_rx_csum = nes_netdev_set_rx_csum,
-+ .get_sg = ethtool_op_get_sg,
-+ .set_sg = ethtool_op_set_sg,
-+ .get_tso = ethtool_op_get_tso,
-+ .set_tso = ethtool_op_set_tso,
-+ .get_flags = ethtool_op_get_flags,
-+ .set_flags = ethtool_op_set_flags
-+#endif
- };
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
-+static void nes_netdev_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
-+{
-+ struct nes_vnic *nesvnic = netdev_priv(netdev);
-+ struct nes_device *nesdev = nesvnic->nesdev;
-+ struct nes_adapter *nesadapter = nesdev->nesadapter;
-+ u32 u32temp;
-+ unsigned long flags;
-+
-+ spin_lock_irqsave(&nesadapter->phy_lock, flags);
-+ nesvnic->vlan_grp = grp;
-+
-+ nes_debug(NES_DBG_NETDEV, "%s: %s\n", __func__, netdev->name);
-+
-+ /* Enable/Disable VLAN Stripping */
-+ u32temp = nes_read_indexed(nesdev, NES_IDX_PCIX_DIAG);
-+ if (grp)
-+ u32temp &= 0xfdffffff;
-+ else
-+ u32temp |= 0x02000000;
-+
-+ nes_write_indexed(nesdev, NES_IDX_PCIX_DIAG, u32temp);
-+ spin_unlock_irqrestore(&nesadapter->phy_lock, flags);
-+}
-+#endif
-+
- static void nes_vlan_mode(struct net_device *netdev, struct nes_device *nesdev, netdev_features_t features)
- {
- struct nes_adapter *nesadapter = nesdev->nesadapter;
-@@ -1608,6 +1682,7 @@ static void nes_vlan_mode(struct net_device *netdev, struct nes_device *nesdev,
- spin_unlock_irqrestore(&nesadapter->phy_lock, flags);
- }
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
- static netdev_features_t nes_fix_features(struct net_device *netdev, netdev_features_t features)
- {
- /*
-@@ -1633,6 +1708,7 @@ static int nes_set_features(struct net_device *netdev, netdev_features_t feature
-
- return 0;
- }
-+#endif
-
- static const struct net_device_ops nes_netdev_ops = {
- .ndo_open = nes_netdev_open,
-@@ -1644,8 +1720,13 @@ static const struct net_device_ops nes_netdev_ops = {
- .ndo_set_rx_mode = nes_netdev_set_multicast_list,
- .ndo_change_mtu = nes_netdev_change_mtu,
- .ndo_validate_addr = eth_validate_addr,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
- .ndo_fix_features = nes_fix_features,
- .ndo_set_features = nes_set_features,
-+#endif
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
-+ .ndo_vlan_rx_register = nes_netdev_vlan_rx_register,
-+#endif
- };
-
- /**
-@@ -1706,12 +1787,15 @@ struct net_device *nes_netdev_init(struct nes_device *nesdev,
- netdev->dev_addr[4] = (u8)(u64temp>>8);
- netdev->dev_addr[5] = (u8)u64temp;
-
-- netdev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX;
-- if ((nesvnic->logical_port < 2) || (nesdev->nesadapter->hw_rev != NE020_REV))
-- netdev->hw_features |= NETIF_F_TSO;
-+ netdev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX;
-+
-+ if ((nesvnic->logical_port < 2) || (nesdev->nesadapter->hw_rev != NE020_REV))
-+ netdev->features |= NETIF_F_TSO;
-
-- netdev->features = netdev->hw_features | NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_TX;
-- netdev->hw_features |= NETIF_F_LRO;
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
-+ netdev->hw_features |= netdev->features | NETIF_F_LRO;
-+#endif
-+ netdev->features |= NETIF_F_HIGHDMA | NETIF_F_HW_VLAN_CTAG_TX;
-
- nes_debug(NES_DBG_INIT, "nesvnic = %p, reported features = 0x%lX, QPid = %d,"
- " nic_index = %d, logical_port = %d, mac_index = %d.\n",
-diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
-index 02120d3..4eb5cf8 100644
---- a/drivers/infiniband/hw/nes/nes_hw.c
-+++ b/drivers/infiniband/hw/nes/nes_hw.c
-@@ -1003,9 +1003,14 @@ int nes_init_cqp(struct nes_device *nesdev)
- (sizeof(struct nes_hw_aeqe) * nesadapter->max_qp) +
- sizeof(struct nes_hw_cqp_qp_context);
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
- nesdev->cqp_vbase = pci_zalloc_consistent(nesdev->pcidev,
- nesdev->cqp_mem_size,
- &nesdev->cqp_pbase);
-+#else
-+ nesdev->cqp_vbase = pci_alloc_consistent(nesdev->pcidev, nesdev->cqp_mem_size,
-+ &nesdev->cqp_pbase);
-+#endif
- if (!nesdev->cqp_vbase) {
- nes_debug(NES_DBG_INIT, "Unable to allocate memory for host descriptor rings\n");
- return -ENOMEM;
-@@ -1691,9 +1696,14 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
- (NES_NIC_WQ_SIZE * 2 * sizeof(struct nes_hw_nic_cqe)) +
- sizeof(struct nes_hw_nic_qp_context);
-
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
- nesvnic->nic_vbase = pci_zalloc_consistent(nesdev->pcidev,
- nesvnic->nic_mem_size,
- &nesvnic->nic_pbase);
-+#else
-+ nesvnic->nic_vbase = pci_alloc_consistent(nesdev->pcidev, nesvnic->nic_mem_size,
-+ &nesvnic->nic_pbase);
-+#endif
- if (!nesvnic->nic_vbase) {
- nes_debug(NES_DBG_INIT, "Unable to allocate memory for NIC host descriptor rings\n");
- return -ENOMEM;
-diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
-index fef067c..a077703 100644
---- a/drivers/infiniband/hw/nes/nes_verbs.c
-+++ b/drivers/infiniband/hw/nes/nes_verbs.c
-@@ -1616,8 +1616,13 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
- entries, nescq->cq_mem_size, nescq->hw_cq.cq_number);
-
- /* allocate the physical buffer space */
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0))
- mem = pci_zalloc_consistent(nesdev->pcidev, nescq->cq_mem_size,
- &nescq->hw_cq.cq_pbase);
-+#else
-+ mem = pci_alloc_consistent(nesdev->pcidev, nescq->cq_mem_size,
-+ &nescq->hw_cq.cq_pbase);
-+#endif
- if (!mem) {
- printk(KERN_ERR PFX "Unable to allocate pci memory for cq\n");
- nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num);
--- /dev/null
+From: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
+Subject: [PATCH] BACKPORT: RDMA/iwpm
+
+Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
+---
+ drivers/infiniband/core/iwpm_util.c | 26 ++++++++++++++++++++++++--
+ 1 files changed, 24 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/infiniband/core/iwpm_util.c b/drivers/infiniband/core/iwpm_util.c
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/core/iwpm_util.c
++++ b/drivers/infiniband/core/iwpm_util.c
+@@ -131,6 +131,9 @@ int iwpm_remove_mapinfo(struct sockaddr_storage *local_sockaddr,
+ struct hlist_node *tmp_hlist_node;
+ struct hlist_head *hash_bucket_head;
+ struct iwpm_mapping_info *map_info = NULL;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++ struct hlist_node *node;
++#endif
+ unsigned long flags;
+ int ret = -EINVAL;
+
+@@ -139,9 +142,13 @@ int iwpm_remove_mapinfo(struct sockaddr_storage *local_sockaddr,
+ hash_bucket_head = get_hash_bucket_head(
+ local_sockaddr,
+ mapped_local_addr);
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++ hlist_for_each_entry_safe(map_info, node, tmp_hlist_node,
++ hash_bucket_head, hlist_node) {
++#else
+ hlist_for_each_entry_safe(map_info, tmp_hlist_node,
+ hash_bucket_head, hlist_node) {
+-
++#endif
+ if (!iwpm_compare_sockaddr(&map_info->mapped_sockaddr,
+ mapped_local_addr)) {
+
+@@ -161,15 +168,22 @@ static void free_hash_bucket(void)
+ {
+ struct hlist_node *tmp_hlist_node;
+ struct iwpm_mapping_info *map_info;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++ struct hlist_node *node;
++#endif
+ unsigned long flags;
+ int i;
+
+ /* remove all the mapinfo data from the list */
+ spin_lock_irqsave(&iwpm_mapinfo_lock, flags);
+ for (i = 0; i < IWPM_HASH_BUCKET_SIZE; i++) {
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++ hlist_for_each_entry_safe(map_info, node, tmp_hlist_node,
++ &iwpm_hash_bucket[i], hlist_node) {
++#else
+ hlist_for_each_entry_safe(map_info, tmp_hlist_node,
+ &iwpm_hash_bucket[i], hlist_node) {
+-
++#endif
+ hlist_del_init(&map_info->hlist_node);
+ kfree(map_info);
+ }
+@@ -498,6 +512,9 @@ int iwpm_send_mapinfo(u8 nl_client, int iwpm_pid)
+ struct iwpm_mapping_info *map_info;
+ struct sk_buff *skb = NULL;
+ struct nlmsghdr *nlh;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++ struct hlist_node *node;
++#endif
+ int skb_num = 0, mapping_num = 0;
+ int i = 0, nlmsg_bytes = 0;
+ unsigned long flags;
+@@ -513,8 +530,13 @@ int iwpm_send_mapinfo(u8 nl_client, int iwpm_pid)
+ skb_num++;
+ spin_lock_irqsave(&iwpm_mapinfo_lock, flags);
+ for (i = 0; i < IWPM_HASH_BUCKET_SIZE; i++) {
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
++ hlist_for_each_entry(map_info, node,
++ &iwpm_hash_bucket[i], hlist_node) {
++#else
+ hlist_for_each_entry(map_info, &iwpm_hash_bucket[i],
+ hlist_node) {
++#endif
+ if (map_info->nl_client != nl_client)
+ continue;
+ nlh = NULL;
+++ /dev/null
-Subject: [PATCH] RDMA/iwpm: Backports for OFED-3.18
-
-Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
----
- drivers/infiniband/core/iwpm_util.c | 26 ++++++++++++++++++++++++--
- 1 files changed, 24 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/infiniband/core/iwpm_util.c b/drivers/infiniband/core/iwpm_util.c
-index 69e9f84..5e01389 100644
---- a/drivers/infiniband/core/iwpm_util.c
-+++ b/drivers/infiniband/core/iwpm_util.c
-@@ -131,6 +131,9 @@ int iwpm_remove_mapinfo(struct sockaddr_storage *local_sockaddr,
- struct hlist_node *tmp_hlist_node;
- struct hlist_head *hash_bucket_head;
- struct iwpm_mapping_info *map_info = NULL;
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+ struct hlist_node *node;
-+#endif
- unsigned long flags;
- int ret = -EINVAL;
-
-@@ -139,9 +142,13 @@ int iwpm_remove_mapinfo(struct sockaddr_storage *local_sockaddr,
- hash_bucket_head = get_hash_bucket_head(
- local_sockaddr,
- mapped_local_addr);
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+ hlist_for_each_entry_safe(map_info, node, tmp_hlist_node,
-+ hash_bucket_head, hlist_node) {
-+#else
- hlist_for_each_entry_safe(map_info, tmp_hlist_node,
- hash_bucket_head, hlist_node) {
--
-+#endif
- if (!iwpm_compare_sockaddr(&map_info->mapped_sockaddr,
- mapped_local_addr)) {
-
-@@ -161,15 +168,22 @@ static void free_hash_bucket(void)
- {
- struct hlist_node *tmp_hlist_node;
- struct iwpm_mapping_info *map_info;
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+ struct hlist_node *node;
-+#endif
- unsigned long flags;
- int i;
-
- /* remove all the mapinfo data from the list */
- spin_lock_irqsave(&iwpm_mapinfo_lock, flags);
- for (i = 0; i < IWPM_HASH_BUCKET_SIZE; i++) {
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+ hlist_for_each_entry_safe(map_info, node, tmp_hlist_node,
-+ &iwpm_hash_bucket[i], hlist_node) {
-+#else
- hlist_for_each_entry_safe(map_info, tmp_hlist_node,
- &iwpm_hash_bucket[i], hlist_node) {
--
-+#endif
- hlist_del_init(&map_info->hlist_node);
- kfree(map_info);
- }
-@@ -498,6 +512,9 @@ int iwpm_send_mapinfo(u8 nl_client, int iwpm_pid)
- struct iwpm_mapping_info *map_info;
- struct sk_buff *skb = NULL;
- struct nlmsghdr *nlh;
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+ struct hlist_node *node;
-+#endif
- int skb_num = 0, mapping_num = 0;
- int i = 0, nlmsg_bytes = 0;
- unsigned long flags;
-@@ -513,8 +530,13 @@ int iwpm_send_mapinfo(u8 nl_client, int iwpm_pid)
- skb_num++;
- spin_lock_irqsave(&iwpm_mapinfo_lock, flags);
- for (i = 0; i < IWPM_HASH_BUCKET_SIZE; i++) {
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0))
-+ hlist_for_each_entry(map_info, node,
-+ &iwpm_hash_bucket[i], hlist_node) {
-+#else
- hlist_for_each_entry(map_info, &iwpm_hash_bucket[i],
- hlist_node) {
-+#endif
- if (map_info->nl_client != nl_client)
- continue;
- nlh = NULL;
---
-1.7.1
-
--- /dev/null
+From: Vipul Pandya <vipul@chelsio.com>
+Subject: [PATCH] BACKPORT: iw_cxgb3/iw_cxgb4 Makefile
+
+Enable header file inclusion with absolute path
+
+iw_cxgb3/iw_cxgb4 driver includes header files of cxgb3/cxgb4 drivers
+respectively. OFED build environment is not able to find the header files
+if absolute path is not given.
+
+Signed-off-by: Vipul Pandya <vipul@chelsio.com>
+---
+ drivers/infiniband/hw/cxgb3/Makefile | 2 +-
+ drivers/infiniband/hw/cxgb4/Makefile | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/infiniband/hw/cxgb3/Makefile b/drivers/infiniband/hw/cxgb3/Makefile
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/hw/cxgb3/Makefile
++++ b/drivers/infiniband/hw/cxgb3/Makefile
+@@ -1,4 +1,4 @@
+-ccflags-y := -Idrivers/net/ethernet/chelsio/cxgb3
++ccflags-y := -I$(CWD)/drivers/net/ethernet/chelsio/cxgb3
+
+ obj-$(CONFIG_INFINIBAND_CXGB3) += iw_cxgb3.o
+
+diff --git a/drivers/infiniband/hw/cxgb4/Makefile b/drivers/infiniband/hw/cxgb4/Makefile
+index xxxxxxx..xxxxxxx xxxxxx
+--- a/drivers/infiniband/hw/cxgb4/Makefile
++++ b/drivers/infiniband/hw/cxgb4/Makefile
+@@ -1,4 +1,4 @@
+-ccflags-y := -Idrivers/net/ethernet/chelsio/cxgb4
++ccflags-y := -I$(CWD)/drivers/net/ethernet/chelsio/cxgb4
+
+ obj-$(CONFIG_INFINIBAND_CXGB4) += iw_cxgb4.o
+