From 7c73e95f057ab571be109b5421530091861e360a Mon Sep 17 00:00:00 2001 From: Vladimir Sokolovsky Date: Wed, 11 Jul 2012 11:28:41 +0300 Subject: [PATCH] Add ib/core backports All backport patches reside in the same directory "patches" These patches being applied by admin_rdma.sh script. Signed-off-by: Vladimir Sokolovsky --- .../0001-ib_core-backport-dst_fetch_ha.patch | 95 ++++++++++++ ...2-ib-core-Backport-flowi4-and-flowi6.patch | 103 +++++++++++++ ...ACKPORT-core-netlink-for-kernels-3.4.patch | 36 +++++ ...e-Backport-pinned_vm-for-kernels-3.2.patch | 65 +++++++++ ...ckport-CLASS_ATTR-for-kernels-2.6.34.patch | 138 ++++++++++++++++++ {backports => patches}/README | 0 6 files changed, 437 insertions(+) create mode 100644 patches/0001-ib_core-backport-dst_fetch_ha.patch create mode 100644 patches/0002-ib-core-Backport-flowi4-and-flowi6.patch create mode 100644 patches/0003-BACKPORT-core-netlink-for-kernels-3.4.patch create mode 100644 patches/0004-ib-core-Backport-pinned_vm-for-kernels-3.2.patch create mode 100644 patches/0005-ib-core-Backport-CLASS_ATTR-for-kernels-2.6.34.patch rename {backports => patches}/README (100%) diff --git a/patches/0001-ib_core-backport-dst_fetch_ha.patch b/patches/0001-ib_core-backport-dst_fetch_ha.patch new file mode 100644 index 0000000..3f033b3 --- /dev/null +++ b/patches/0001-ib_core-backport-dst_fetch_ha.patch @@ -0,0 +1,95 @@ +From 5d26d2ca164af6b639e7862105a7491b217847e5 Mon Sep 17 00:00:00 2001 +From: Vladimir Sokolovsky +Date: Tue, 10 Jul 2012 15:57:24 +0300 +Subject: [PATCH 1/5] ib_core: backport dst_fetch_ha + +Signed-off-by: Vladimir Sokolovsky +--- + drivers/infiniband/core/addr.c | 36 ++++++++++++++++++++++++++++++++++++ + 1 files changed, 36 insertions(+), 0 deletions(-) + +diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c +index 6ef660c..e00422b 100644 +--- a/drivers/infiniband/core/addr.c ++++ b/drivers/infiniband/core/addr.c +@@ -38,6 +38,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -178,6 +179,7 @@ static void queue_req(struct addr_req *req) + mutex_unlock(&lock); + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) + static int dst_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *dev_addr, void *daddr) + { + struct neighbour *n; +@@ -200,6 +202,7 @@ static int dst_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *dev_addr, v + + return ret; + } ++#endif + + static int addr4_resolve(struct sockaddr_in *src_in, + struct sockaddr_in *dst_in, +@@ -231,12 +234,33 @@ 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; + } + + ret = dst_fetch_ha(&rt->dst, addr, &fl4.daddr); ++#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: +@@ -284,7 +308,19 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, + goto put; + } + ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) + ret = dst_fetch_ha(dst, addr, &fl6.daddr); ++#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; +-- +1.7.1 + diff --git a/patches/0002-ib-core-Backport-flowi4-and-flowi6.patch b/patches/0002-ib-core-Backport-flowi4-and-flowi6.patch new file mode 100644 index 0000000..efee254 --- /dev/null +++ b/patches/0002-ib-core-Backport-flowi4-and-flowi6.patch @@ -0,0 +1,103 @@ +From 2c405873e4741984cd75e7dcbcdb2ab81ac34431 Mon Sep 17 00:00:00 2001 +From: Vladimir Sokolovsky +Date: Tue, 10 Jul 2012 17:21:25 +0300 +Subject: [PATCH 2/5] ib/core: Backport flowi4 and flowi6 + +Signed-off-by: Vladimir Sokolovsky +--- + drivers/infiniband/core/addr.c | 45 ++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 45 insertions(+), 0 deletions(-) + +diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c +index e00422b..dbb8bcd 100644 +--- a/drivers/infiniband/core/addr.c ++++ b/drivers/infiniband/core/addr.c +@@ -211,22 +211,41 @@ 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; + fl4.flowi4_oif = addr->bound_dev_if; + rt = ip_route_output_key(&init_net, &fl4); ++#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); ++#endif + if (IS_ERR(rt)) { + ret = PTR_ERR(rt); + goto out; + } + 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); + if (!ret) + memcpy(addr->dst_dev_addr, addr->src_dev_addr, MAX_ADDR_LEN); +@@ -272,10 +291,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; +@@ -294,6 +319,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); +-- +1.7.1 + diff --git a/patches/0003-BACKPORT-core-netlink-for-kernels-3.4.patch b/patches/0003-BACKPORT-core-netlink-for-kernels-3.4.patch new file mode 100644 index 0000000..d8617e5 --- /dev/null +++ b/patches/0003-BACKPORT-core-netlink-for-kernels-3.4.patch @@ -0,0 +1,36 @@ +From c72b46457d5e88bea77d59bc486a12ec3ad0a80a Mon Sep 17 00:00:00 2001 +From: Vladimir Sokolovsky +Date: Mon, 25 Jun 2012 22:28:24 +0300 +Subject: [PATCH 3/5] BACKPORT: core/netlink for kernels <= 3.4 + +Signed-off-by: Vladimir Sokolovsky +--- + drivers/infiniband/core/netlink.c | 6 ++++++ + 1 files changed, 6 insertions(+), 0 deletions(-) + +diff --git a/drivers/infiniband/core/netlink.c b/drivers/infiniband/core/netlink.c +index e497dfb..2ac867a 100644 +--- a/drivers/infiniband/core/netlink.c ++++ b/drivers/infiniband/core/netlink.c +@@ -149,12 +149,18 @@ static int ibnl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) + !client->cb_table[RDMA_NL_GET_OP(op)].dump) + return -EINVAL; + ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) + { + struct netlink_dump_control c = { + .dump = client->cb_table[op].dump, + }; + 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)) */ + } + } + +-- +1.7.1 + diff --git a/patches/0004-ib-core-Backport-pinned_vm-for-kernels-3.2.patch b/patches/0004-ib-core-Backport-pinned_vm-for-kernels-3.2.patch new file mode 100644 index 0000000..9ecf5fc --- /dev/null +++ b/patches/0004-ib-core-Backport-pinned_vm-for-kernels-3.2.patch @@ -0,0 +1,65 @@ +From 39e81c844d77792b939619bb4e8ad212640fd801 Mon Sep 17 00:00:00 2001 +From: Vladimir Sokolovsky +Date: Tue, 10 Jul 2012 17:41:31 +0300 +Subject: [PATCH 4/5] ib/core: Backport pinned_vm for kernels <= 3.2 + +Signed-off-by: Vladimir Sokolovsky +--- + drivers/infiniband/core/umem.c | 16 ++++++++++++++++ + 1 files changed, 16 insertions(+), 0 deletions(-) + +diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c +index a841123..3b6cb84 100644 +--- 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)) + current->mm->pinned_vm -= diff; ++#else ++ current->mm->locked_vm -= diff; ++#endif + up_write(&mm->mmap_sem); + mmput(mm); + kfree(umem); +-- +1.7.1 + diff --git a/patches/0005-ib-core-Backport-CLASS_ATTR-for-kernels-2.6.34.patch b/patches/0005-ib-core-Backport-CLASS_ATTR-for-kernels-2.6.34.patch new file mode 100644 index 0000000..024afa8 --- /dev/null +++ b/patches/0005-ib-core-Backport-CLASS_ATTR-for-kernels-2.6.34.patch @@ -0,0 +1,138 @@ +From b9bb7ce447837b2b8f732f06196b4590df1128d7 Mon Sep 17 00:00:00 2001 +From: Vladimir Sokolovsky +Date: Tue, 10 Jul 2012 18:06:16 +0300 +Subject: [PATCH 5/5] ib/core: Backport CLASS_ATTR for kernels < 2.6.34 + +Signed-off-by: Vladimir Sokolovsky +--- + drivers/infiniband/core/ucm.c | 20 ++++++++++++++++++++ + drivers/infiniband/core/user_mad.c | 12 ++++++++++++ + drivers/infiniband/core/uverbs_main.c | 12 ++++++++++++ + 3 files changed, 44 insertions(+), 0 deletions(-) + +diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c +index 06f0871..d74c8b3 100644 +--- a/drivers/infiniband/core/ucm.c ++++ b/drivers/infiniband/core/ucm.c +@@ -1330,8 +1330,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) + { +@@ -1344,7 +1352,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; +@@ -1358,7 +1370,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: +@@ -1368,7 +1384,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/user_mad.c b/drivers/infiniband/core/user_mad.c +index f0d588f..2a31027 100644 +--- 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); +@@ -1200,7 +1208,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_main.c b/drivers/infiniband/core/uverbs_main.c +index 604556d..4b0d8f3 100644 +--- a/drivers/infiniband/core/uverbs_main.c ++++ b/drivers/infiniband/core/uverbs_main.c +@@ -715,8 +715,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); +@@ -873,7 +881,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; +-- +1.7.1 + diff --git a/backports/README b/patches/README similarity index 100% rename from backports/README rename to patches/README -- 2.41.0