Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d0d62c34 authored by Doug Ledford's avatar Doug Ledford
Browse files

Merge branch 'rdma-netlink' into k.o/merge-test



Conflicts:
	include/rdma/ib_verbs.h - Modified a function signature adjacent
	to a newly added function signature from a previous merge

Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parents 32043830 db14dff1
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -11,7 +11,8 @@ ib_core-y := packer.o ud_header.o verbs.o cq.o rw.o sysfs.o \
				device.o fmr_pool.o cache.o netlink.o \
				device.o fmr_pool.o cache.o netlink.o \
				roce_gid_mgmt.o mr_pool.o addr.o sa_query.o \
				roce_gid_mgmt.o mr_pool.o addr.o sa_query.o \
				multicast.o mad.o smi.o agent.o mad_rmpp.o \
				multicast.o mad.o smi.o agent.o mad_rmpp.o \
				security.o
				security.o nldev.o

ib_core-$(CONFIG_INFINIBAND_USER_MEM) += umem.o
ib_core-$(CONFIG_INFINIBAND_USER_MEM) += umem.o
ib_core-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o umem_rbtree.o
ib_core-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o umem_rbtree.o
ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o
ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o
+5 −7
Original line number Original line Diff line number Diff line
@@ -129,13 +129,11 @@ static void ib_nl_process_good_ip_rsep(const struct nlmsghdr *nlh)
}
}


int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
			     struct netlink_callback *cb)
			     struct nlmsghdr *nlh,
			     struct netlink_ext_ack *extack)
{
{
	const struct nlmsghdr *nlh = (struct nlmsghdr *)cb->nlh;

	if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
	if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
	    !(NETLINK_CB(skb).sk) ||
	    !(NETLINK_CB(skb).sk))
	    !netlink_capable(skb, CAP_NET_ADMIN))
		return -EPERM;
		return -EPERM;


	if (ib_nl_is_good_ip_resp(nlh))
	if (ib_nl_is_good_ip_resp(nlh))
@@ -185,7 +183,7 @@ static int ib_nl_ip_send_msg(struct rdma_dev_addr *dev_addr,


	/* Repair the nlmsg header length */
	/* Repair the nlmsg header length */
	nlmsg_end(skb, nlh);
	nlmsg_end(skb, nlh);
	ibnl_multicast(skb, nlh, RDMA_NL_GROUP_LS, GFP_KERNEL);
	rdma_nl_multicast(skb, RDMA_NL_GROUP_LS, GFP_KERNEL);


	/* Make the request retry, so when we get the response from userspace
	/* Make the request retry, so when we get the response from userspace
	 * we will have something.
	 * we will have something.
@@ -326,7 +324,7 @@ static void queue_req(struct addr_req *req)
static int ib_nl_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *dev_addr,
static int ib_nl_fetch_ha(struct dst_entry *dst, struct rdma_dev_addr *dev_addr,
			  const void *daddr, u32 seq, u16 family)
			  const void *daddr, u32 seq, u16 family)
{
{
	if (ibnl_chk_listeners(RDMA_NL_GROUP_LS))
	if (rdma_nl_chk_listeners(RDMA_NL_GROUP_LS))
		return -EADDRNOTAVAIL;
		return -EADDRNOTAVAIL;


	/* We fill in what we can, the response will fill the rest */
	/* We fill in what we can, the response will fill the rest */
+4 −7
Original line number Original line Diff line number Diff line
@@ -4458,9 +4458,8 @@ static int cma_get_id_stats(struct sk_buff *skb, struct netlink_callback *cb)
	return skb->len;
	return skb->len;
}
}


static const struct ibnl_client_cbs cma_cb_table[] = {
static const struct rdma_nl_cbs cma_cb_table[] = {
	[RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats,
	[RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats},
				       .module = THIS_MODULE },
};
};


static int cma_init_net(struct net *net)
static int cma_init_net(struct net *net)
@@ -4512,9 +4511,7 @@ static int __init cma_init(void)
	if (ret)
	if (ret)
		goto err;
		goto err;


	if (ibnl_add_client(RDMA_NL_RDMA_CM, ARRAY_SIZE(cma_cb_table),
	rdma_nl_register(RDMA_NL_RDMA_CM, cma_cb_table);
			    cma_cb_table))
		pr_warn("RDMA CMA: failed to add netlink callback\n");
	cma_configfs_init();
	cma_configfs_init();


	return 0;
	return 0;
@@ -4531,7 +4528,7 @@ static int __init cma_init(void)
static void __exit cma_cleanup(void)
static void __exit cma_cleanup(void)
{
{
	cma_configfs_exit();
	cma_configfs_exit();
	ibnl_remove_client(RDMA_NL_RDMA_CM);
	rdma_nl_unregister(RDMA_NL_RDMA_CM);
	ib_unregister_client(&cma_client);
	ib_unregister_client(&cma_client);
	unregister_netdevice_notifier(&cma_nb);
	unregister_netdevice_notifier(&cma_nb);
	rdma_addr_unregister_client(&addr_client);
	rdma_addr_unregister_client(&addr_client);
+21 −5
Original line number Original line Diff line number Diff line
@@ -103,6 +103,14 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter,
			      roce_netdev_callback cb,
			      roce_netdev_callback cb,
			      void *cookie);
			      void *cookie);


typedef int (*nldev_callback)(struct ib_device *device,
			      struct sk_buff *skb,
			      struct netlink_callback *cb,
			      unsigned int idx);

int ib_enum_all_devs(nldev_callback nldev_cb, struct sk_buff *skb,
		     struct netlink_callback *cb);

enum ib_cache_gid_default_mode {
enum ib_cache_gid_default_mode {
	IB_CACHE_GID_DEFAULT_MODE_SET,
	IB_CACHE_GID_DEFAULT_MODE_SET,
	IB_CACHE_GID_DEFAULT_MODE_DELETE
	IB_CACHE_GID_DEFAULT_MODE_DELETE
@@ -180,8 +188,8 @@ void ib_mad_cleanup(void);
int ib_sa_init(void);
int ib_sa_init(void);
void ib_sa_cleanup(void);
void ib_sa_cleanup(void);


int ibnl_init(void);
int rdma_nl_init(void);
void ibnl_cleanup(void);
void rdma_nl_exit(void);


/**
/**
 * Check if there are any listeners to the netlink group
 * Check if there are any listeners to the netlink group
@@ -191,11 +199,14 @@ void ibnl_cleanup(void);
int ibnl_chk_listeners(unsigned int group);
int ibnl_chk_listeners(unsigned int group);


int ib_nl_handle_resolve_resp(struct sk_buff *skb,
int ib_nl_handle_resolve_resp(struct sk_buff *skb,
			      struct netlink_callback *cb);
			      struct nlmsghdr *nlh,
			      struct netlink_ext_ack *extack);
int ib_nl_handle_set_timeout(struct sk_buff *skb,
int ib_nl_handle_set_timeout(struct sk_buff *skb,
			     struct netlink_callback *cb);
			     struct nlmsghdr *nlh,
			     struct netlink_ext_ack *extack);
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
			     struct netlink_callback *cb);
			     struct nlmsghdr *nlh,
			     struct netlink_ext_ack *extack);


int ib_get_cached_subnet_prefix(struct ib_device *device,
int ib_get_cached_subnet_prefix(struct ib_device *device,
				u8                port_num,
				u8                port_num,
@@ -302,4 +313,9 @@ static inline int ib_mad_enforce_security(struct ib_mad_agent_private *map,
	return 0;
	return 0;
}
}
#endif
#endif

struct ib_device *__ib_device_get_by_index(u32 ifindex);
/* RDMA device netlink */
void nldev_init(void);
void nldev_exit(void);
#endif /* _CORE_PRIV_H */
#endif /* _CORE_PRIV_H */
+83 −36
Original line number Original line Diff line number Diff line
@@ -134,6 +134,17 @@ static int ib_device_check_mandatory(struct ib_device *device)
	return 0;
	return 0;
}
}


struct ib_device *__ib_device_get_by_index(u32 index)
{
	struct ib_device *device;

	list_for_each_entry(device, &device_list, core_list)
		if (device->index == index)
			return device;

	return NULL;
}

static struct ib_device *__ib_device_get_by_name(const char *name)
static struct ib_device *__ib_device_get_by_name(const char *name)
{
{
	struct ib_device *device;
	struct ib_device *device;
@@ -145,7 +156,6 @@ static struct ib_device *__ib_device_get_by_name(const char *name)
	return NULL;
	return NULL;
}
}



static int alloc_name(char *name)
static int alloc_name(char *name)
{
{
	unsigned long *inuse;
	unsigned long *inuse;
@@ -326,10 +336,10 @@ static int read_port_immutable(struct ib_device *device)
	return 0;
	return 0;
}
}


void ib_get_device_fw_str(struct ib_device *dev, char *str, size_t str_len)
void ib_get_device_fw_str(struct ib_device *dev, char *str)
{
{
	if (dev->get_dev_fw_str)
	if (dev->get_dev_fw_str)
		dev->get_dev_fw_str(dev, str, str_len);
		dev->get_dev_fw_str(dev, str);
	else
	else
		str[0] = '\0';
		str[0] = '\0';
}
}
@@ -394,6 +404,30 @@ static int ib_security_change(struct notifier_block *nb, unsigned long event,
	return NOTIFY_OK;
	return NOTIFY_OK;
}
}


/**
 *	__dev_new_index	-	allocate an device index
 *
 *	Returns a suitable unique value for a new device interface
 *	number.  It assumes that there are less than 2^32-1 ib devices
 *	will be present in the system.
 */
static u32 __dev_new_index(void)
{
	/*
	 * The device index to allow stable naming.
	 * Similar to struct net -> ifindex.
	 */
	static u32 index;

	for (;;) {
		if (!(++index))
			index = 1;

		if (!__ib_device_get_by_index(index))
			return index;
	}
}

/**
/**
 * ib_register_device - Register an IB device with IB core
 * ib_register_device - Register an IB device with IB core
 * @device:Device to register
 * @device:Device to register
@@ -492,6 +526,7 @@ int ib_register_device(struct ib_device *device,
		if (client->add && !add_client_context(device, client))
		if (client->add && !add_client_context(device, client))
			client->add(device);
			client->add(device);


	device->index = __dev_new_index();
	down_write(&lists_rwsem);
	down_write(&lists_rwsem);
	list_add_tail(&device->core_list, &device_list);
	list_add_tail(&device->core_list, &device_list);
	up_write(&lists_rwsem);
	up_write(&lists_rwsem);
@@ -892,6 +927,31 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter,
	up_read(&lists_rwsem);
	up_read(&lists_rwsem);
}
}


/**
 * ib_enum_all_devs - enumerate all ib_devices
 * @cb: Callback to call for each found ib_device
 *
 * Enumerates all ib_devices and calls callback() on each device.
 */
int ib_enum_all_devs(nldev_callback nldev_cb, struct sk_buff *skb,
		     struct netlink_callback *cb)
{
	struct ib_device *dev;
	unsigned int idx = 0;
	int ret = 0;

	down_read(&lists_rwsem);
	list_for_each_entry(dev, &device_list, core_list) {
		ret = nldev_cb(dev, skb, cb, idx);
		if (ret)
			break;
		idx++;
	}

	up_read(&lists_rwsem);
	return ret;
}

/**
/**
 * ib_query_pkey - Get P_Key table entry
 * ib_query_pkey - Get P_Key table entry
 * @device:Device to query
 * @device:Device to query
@@ -1086,29 +1146,21 @@ struct net_device *ib_get_net_dev_by_params(struct ib_device *dev,
}
}
EXPORT_SYMBOL(ib_get_net_dev_by_params);
EXPORT_SYMBOL(ib_get_net_dev_by_params);


static struct ibnl_client_cbs ibnl_ls_cb_table[] = {
static const struct rdma_nl_cbs ibnl_ls_cb_table[] = {
	[RDMA_NL_LS_OP_RESOLVE] = {
	[RDMA_NL_LS_OP_RESOLVE] = {
		.dump = ib_nl_handle_resolve_resp,
		.doit = ib_nl_handle_resolve_resp,
		.module = THIS_MODULE },
		.flags = RDMA_NL_ADMIN_PERM,
	},
	[RDMA_NL_LS_OP_SET_TIMEOUT] = {
	[RDMA_NL_LS_OP_SET_TIMEOUT] = {
		.dump = ib_nl_handle_set_timeout,
		.doit = ib_nl_handle_set_timeout,
		.module = THIS_MODULE },
		.flags = RDMA_NL_ADMIN_PERM,
	},
	[RDMA_NL_LS_OP_IP_RESOLVE] = {
	[RDMA_NL_LS_OP_IP_RESOLVE] = {
		.dump = ib_nl_handle_ip_res_resp,
		.doit = ib_nl_handle_ip_res_resp,
		.module = THIS_MODULE },
		.flags = RDMA_NL_ADMIN_PERM,
	},
};
};


static int ib_add_ibnl_clients(void)
{
	return ibnl_add_client(RDMA_NL_LS, ARRAY_SIZE(ibnl_ls_cb_table),
			       ibnl_ls_cb_table);
}

static void ib_remove_ibnl_clients(void)
{
	ibnl_remove_client(RDMA_NL_LS);
}

static int __init ib_core_init(void)
static int __init ib_core_init(void)
{
{
	int ret;
	int ret;
@@ -1130,9 +1182,9 @@ static int __init ib_core_init(void)
		goto err_comp;
		goto err_comp;
	}
	}


	ret = ibnl_init();
	ret = rdma_nl_init();
	if (ret) {
	if (ret) {
		pr_warn("Couldn't init IB netlink interface\n");
		pr_warn("Couldn't init IB netlink interface: err %d\n", ret);
		goto err_sysfs;
		goto err_sysfs;
	}
	}


@@ -1154,24 +1206,18 @@ static int __init ib_core_init(void)
		goto err_mad;
		goto err_mad;
	}
	}


	ret = ib_add_ibnl_clients();
	if (ret) {
		pr_warn("Couldn't register ibnl clients\n");
		goto err_sa;
	}

	ret = register_lsm_notifier(&ibdev_lsm_nb);
	ret = register_lsm_notifier(&ibdev_lsm_nb);
	if (ret) {
	if (ret) {
		pr_warn("Couldn't register LSM notifier. ret %d\n", ret);
		pr_warn("Couldn't register LSM notifier. ret %d\n", ret);
		goto err_ibnl_clients;
		goto err_sa;
	}
	}


	nldev_init();
	rdma_nl_register(RDMA_NL_LS, ibnl_ls_cb_table);
	ib_cache_setup();
	ib_cache_setup();


	return 0;
	return 0;


err_ibnl_clients:
	ib_remove_ibnl_clients();
err_sa:
err_sa:
	ib_sa_cleanup();
	ib_sa_cleanup();
err_mad:
err_mad:
@@ -1179,7 +1225,7 @@ static int __init ib_core_init(void)
err_addr:
err_addr:
	addr_cleanup();
	addr_cleanup();
err_ibnl:
err_ibnl:
	ibnl_cleanup();
	rdma_nl_exit();
err_sysfs:
err_sysfs:
	class_unregister(&ib_class);
	class_unregister(&ib_class);
err_comp:
err_comp:
@@ -1191,13 +1237,14 @@ static int __init ib_core_init(void)


static void __exit ib_core_cleanup(void)
static void __exit ib_core_cleanup(void)
{
{
	unregister_lsm_notifier(&ibdev_lsm_nb);
	ib_cache_cleanup();
	ib_cache_cleanup();
	ib_remove_ibnl_clients();
	nldev_exit();
	rdma_nl_unregister(RDMA_NL_LS);
	unregister_lsm_notifier(&ibdev_lsm_nb);
	ib_sa_cleanup();
	ib_sa_cleanup();
	ib_mad_cleanup();
	ib_mad_cleanup();
	addr_cleanup();
	addr_cleanup();
	ibnl_cleanup();
	rdma_nl_exit();
	class_unregister(&ib_class);
	class_unregister(&ib_class);
	destroy_workqueue(ib_comp_wq);
	destroy_workqueue(ib_comp_wq);
	/* Make sure that any pending umem accounting work is done. */
	/* Make sure that any pending umem accounting work is done. */
Loading