diff options
Diffstat (limited to 'drivers/infiniband/core')
| -rw-r--r-- | drivers/infiniband/core/device.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index ce317e623862..a9a27816991a 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
| 39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
| 40 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
| 41 | #include <linux/netdevice.h> | ||
| 41 | #include <rdma/rdma_netlink.h> | 42 | #include <rdma/rdma_netlink.h> |
| 42 | 43 | ||
| 43 | #include "core_priv.h" | 44 | #include "core_priv.h" |
| @@ -780,6 +781,51 @@ int ib_find_pkey(struct ib_device *device, | |||
| 780 | } | 781 | } |
| 781 | EXPORT_SYMBOL(ib_find_pkey); | 782 | EXPORT_SYMBOL(ib_find_pkey); |
| 782 | 783 | ||
| 784 | /** | ||
| 785 | * ib_get_net_dev_by_params() - Return the appropriate net_dev | ||
| 786 | * for a received CM request | ||
| 787 | * @dev: An RDMA device on which the request has been received. | ||
| 788 | * @port: Port number on the RDMA device. | ||
| 789 | * @pkey: The Pkey the request came on. | ||
| 790 | * @gid: A GID that the net_dev uses to communicate. | ||
| 791 | * @addr: Contains the IP address that the request specified as its | ||
| 792 | * destination. | ||
| 793 | */ | ||
| 794 | struct net_device *ib_get_net_dev_by_params(struct ib_device *dev, | ||
| 795 | u8 port, | ||
| 796 | u16 pkey, | ||
| 797 | const union ib_gid *gid, | ||
| 798 | const struct sockaddr *addr) | ||
| 799 | { | ||
| 800 | struct net_device *net_dev = NULL; | ||
| 801 | struct ib_client_data *context; | ||
| 802 | |||
| 803 | if (!rdma_protocol_ib(dev, port)) | ||
| 804 | return NULL; | ||
| 805 | |||
| 806 | down_read(&lists_rwsem); | ||
| 807 | |||
| 808 | list_for_each_entry(context, &dev->client_data_list, list) { | ||
| 809 | struct ib_client *client = context->client; | ||
| 810 | |||
| 811 | if (context->going_down) | ||
| 812 | continue; | ||
| 813 | |||
| 814 | if (client->get_net_dev_by_params) { | ||
| 815 | net_dev = client->get_net_dev_by_params(dev, port, pkey, | ||
| 816 | gid, addr, | ||
| 817 | context->data); | ||
| 818 | if (net_dev) | ||
| 819 | break; | ||
| 820 | } | ||
| 821 | } | ||
| 822 | |||
| 823 | up_read(&lists_rwsem); | ||
| 824 | |||
| 825 | return net_dev; | ||
| 826 | } | ||
| 827 | EXPORT_SYMBOL(ib_get_net_dev_by_params); | ||
| 828 | |||
| 783 | static int __init ib_core_init(void) | 829 | static int __init ib_core_init(void) |
| 784 | { | 830 | { |
| 785 | int ret; | 831 | int ret; |
