Loading drivers/infiniband/core/Makefile +2 −1 Original line number Diff line number Diff line Loading @@ -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 \ roce_gid_mgmt.o mr_pool.o addr.o sa_query.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_ON_DEMAND_PAGING) += umem_odp.o umem_rbtree.o ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o Loading drivers/infiniband/core/addr.c +5 −7 Original line number Diff line number Diff line Loading @@ -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, 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) || !(NETLINK_CB(skb).sk) || !netlink_capable(skb, CAP_NET_ADMIN)) !(NETLINK_CB(skb).sk)) return -EPERM; if (ib_nl_is_good_ip_resp(nlh)) Loading Loading @@ -185,7 +183,7 @@ static int ib_nl_ip_send_msg(struct rdma_dev_addr *dev_addr, /* Repair the nlmsg header length */ 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 * we will have something. Loading Loading @@ -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, 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; /* We fill in what we can, the response will fill the rest */ Loading drivers/infiniband/core/cma.c +4 −7 Original line number Diff line number Diff line Loading @@ -4458,9 +4458,8 @@ static int cma_get_id_stats(struct sk_buff *skb, struct netlink_callback *cb) return skb->len; } static const struct ibnl_client_cbs cma_cb_table[] = { [RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats, .module = THIS_MODULE }, static const struct rdma_nl_cbs cma_cb_table[] = { [RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats}, }; static int cma_init_net(struct net *net) Loading Loading @@ -4512,9 +4511,7 @@ static int __init cma_init(void) if (ret) goto err; if (ibnl_add_client(RDMA_NL_RDMA_CM, ARRAY_SIZE(cma_cb_table), cma_cb_table)) pr_warn("RDMA CMA: failed to add netlink callback\n"); rdma_nl_register(RDMA_NL_RDMA_CM, cma_cb_table); cma_configfs_init(); return 0; Loading @@ -4531,7 +4528,7 @@ static int __init cma_init(void) static void __exit cma_cleanup(void) { cma_configfs_exit(); ibnl_remove_client(RDMA_NL_RDMA_CM); rdma_nl_unregister(RDMA_NL_RDMA_CM); ib_unregister_client(&cma_client); unregister_netdevice_notifier(&cma_nb); rdma_addr_unregister_client(&addr_client); Loading drivers/infiniband/core/core_priv.h +21 −5 Original line number Diff line number Diff line Loading @@ -103,6 +103,14 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter, roce_netdev_callback cb, 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 { IB_CACHE_GID_DEFAULT_MODE_SET, IB_CACHE_GID_DEFAULT_MODE_DELETE Loading Loading @@ -180,8 +188,8 @@ void ib_mad_cleanup(void); int ib_sa_init(void); void ib_sa_cleanup(void); int ibnl_init(void); void ibnl_cleanup(void); int rdma_nl_init(void); void rdma_nl_exit(void); /** * Check if there are any listeners to the netlink group Loading @@ -191,11 +199,14 @@ void ibnl_cleanup(void); int ibnl_chk_listeners(unsigned int group); 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, struct netlink_callback *cb); struct nlmsghdr *nlh, struct netlink_ext_ack *extack); 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, u8 port_num, Loading Loading @@ -302,4 +313,9 @@ static inline int ib_mad_enforce_security(struct ib_mad_agent_private *map, return 0; } #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 */ drivers/infiniband/core/device.c +83 −36 Original line number Diff line number Diff line Loading @@ -134,6 +134,17 @@ static int ib_device_check_mandatory(struct ib_device *device) 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) { struct ib_device *device; Loading @@ -145,7 +156,6 @@ static struct ib_device *__ib_device_get_by_name(const char *name) return NULL; } static int alloc_name(char *name) { unsigned long *inuse; Loading Loading @@ -326,10 +336,10 @@ static int read_port_immutable(struct ib_device *device) 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) dev->get_dev_fw_str(dev, str, str_len); dev->get_dev_fw_str(dev, str); else str[0] = '\0'; } Loading Loading @@ -394,6 +404,30 @@ static int ib_security_change(struct notifier_block *nb, unsigned long event, 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 * @device:Device to register Loading Loading @@ -492,6 +526,7 @@ int ib_register_device(struct ib_device *device, if (client->add && !add_client_context(device, client)) client->add(device); device->index = __dev_new_index(); down_write(&lists_rwsem); list_add_tail(&device->core_list, &device_list); up_write(&lists_rwsem); Loading Loading @@ -892,6 +927,31 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter, 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 * @device:Device to query Loading Loading @@ -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); static struct ibnl_client_cbs ibnl_ls_cb_table[] = { static const struct rdma_nl_cbs ibnl_ls_cb_table[] = { [RDMA_NL_LS_OP_RESOLVE] = { .dump = ib_nl_handle_resolve_resp, .module = THIS_MODULE }, .doit = ib_nl_handle_resolve_resp, .flags = RDMA_NL_ADMIN_PERM, }, [RDMA_NL_LS_OP_SET_TIMEOUT] = { .dump = ib_nl_handle_set_timeout, .module = THIS_MODULE }, .doit = ib_nl_handle_set_timeout, .flags = RDMA_NL_ADMIN_PERM, }, [RDMA_NL_LS_OP_IP_RESOLVE] = { .dump = ib_nl_handle_ip_res_resp, .module = THIS_MODULE }, .doit = ib_nl_handle_ip_res_resp, .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) { int ret; Loading @@ -1130,9 +1182,9 @@ static int __init ib_core_init(void) goto err_comp; } ret = ibnl_init(); ret = rdma_nl_init(); 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; } Loading @@ -1154,24 +1206,18 @@ static int __init ib_core_init(void) 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); if (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(); return 0; err_ibnl_clients: ib_remove_ibnl_clients(); err_sa: ib_sa_cleanup(); err_mad: Loading @@ -1179,7 +1225,7 @@ static int __init ib_core_init(void) err_addr: addr_cleanup(); err_ibnl: ibnl_cleanup(); rdma_nl_exit(); err_sysfs: class_unregister(&ib_class); err_comp: Loading @@ -1191,13 +1237,14 @@ static int __init ib_core_init(void) static void __exit ib_core_cleanup(void) { unregister_lsm_notifier(&ibdev_lsm_nb); 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_mad_cleanup(); addr_cleanup(); ibnl_cleanup(); rdma_nl_exit(); class_unregister(&ib_class); destroy_workqueue(ib_comp_wq); /* Make sure that any pending umem accounting work is done. */ Loading Loading
drivers/infiniband/core/Makefile +2 −1 Original line number Diff line number Diff line Loading @@ -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 \ roce_gid_mgmt.o mr_pool.o addr.o sa_query.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_ON_DEMAND_PAGING) += umem_odp.o umem_rbtree.o ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o Loading
drivers/infiniband/core/addr.c +5 −7 Original line number Diff line number Diff line Loading @@ -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, 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) || !(NETLINK_CB(skb).sk) || !netlink_capable(skb, CAP_NET_ADMIN)) !(NETLINK_CB(skb).sk)) return -EPERM; if (ib_nl_is_good_ip_resp(nlh)) Loading Loading @@ -185,7 +183,7 @@ static int ib_nl_ip_send_msg(struct rdma_dev_addr *dev_addr, /* Repair the nlmsg header length */ 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 * we will have something. Loading Loading @@ -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, 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; /* We fill in what we can, the response will fill the rest */ Loading
drivers/infiniband/core/cma.c +4 −7 Original line number Diff line number Diff line Loading @@ -4458,9 +4458,8 @@ static int cma_get_id_stats(struct sk_buff *skb, struct netlink_callback *cb) return skb->len; } static const struct ibnl_client_cbs cma_cb_table[] = { [RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats, .module = THIS_MODULE }, static const struct rdma_nl_cbs cma_cb_table[] = { [RDMA_NL_RDMA_CM_ID_STATS] = { .dump = cma_get_id_stats}, }; static int cma_init_net(struct net *net) Loading Loading @@ -4512,9 +4511,7 @@ static int __init cma_init(void) if (ret) goto err; if (ibnl_add_client(RDMA_NL_RDMA_CM, ARRAY_SIZE(cma_cb_table), cma_cb_table)) pr_warn("RDMA CMA: failed to add netlink callback\n"); rdma_nl_register(RDMA_NL_RDMA_CM, cma_cb_table); cma_configfs_init(); return 0; Loading @@ -4531,7 +4528,7 @@ static int __init cma_init(void) static void __exit cma_cleanup(void) { cma_configfs_exit(); ibnl_remove_client(RDMA_NL_RDMA_CM); rdma_nl_unregister(RDMA_NL_RDMA_CM); ib_unregister_client(&cma_client); unregister_netdevice_notifier(&cma_nb); rdma_addr_unregister_client(&addr_client); Loading
drivers/infiniband/core/core_priv.h +21 −5 Original line number Diff line number Diff line Loading @@ -103,6 +103,14 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter, roce_netdev_callback cb, 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 { IB_CACHE_GID_DEFAULT_MODE_SET, IB_CACHE_GID_DEFAULT_MODE_DELETE Loading Loading @@ -180,8 +188,8 @@ void ib_mad_cleanup(void); int ib_sa_init(void); void ib_sa_cleanup(void); int ibnl_init(void); void ibnl_cleanup(void); int rdma_nl_init(void); void rdma_nl_exit(void); /** * Check if there are any listeners to the netlink group Loading @@ -191,11 +199,14 @@ void ibnl_cleanup(void); int ibnl_chk_listeners(unsigned int group); 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, struct netlink_callback *cb); struct nlmsghdr *nlh, struct netlink_ext_ack *extack); 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, u8 port_num, Loading Loading @@ -302,4 +313,9 @@ static inline int ib_mad_enforce_security(struct ib_mad_agent_private *map, return 0; } #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 */
drivers/infiniband/core/device.c +83 −36 Original line number Diff line number Diff line Loading @@ -134,6 +134,17 @@ static int ib_device_check_mandatory(struct ib_device *device) 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) { struct ib_device *device; Loading @@ -145,7 +156,6 @@ static struct ib_device *__ib_device_get_by_name(const char *name) return NULL; } static int alloc_name(char *name) { unsigned long *inuse; Loading Loading @@ -326,10 +336,10 @@ static int read_port_immutable(struct ib_device *device) 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) dev->get_dev_fw_str(dev, str, str_len); dev->get_dev_fw_str(dev, str); else str[0] = '\0'; } Loading Loading @@ -394,6 +404,30 @@ static int ib_security_change(struct notifier_block *nb, unsigned long event, 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 * @device:Device to register Loading Loading @@ -492,6 +526,7 @@ int ib_register_device(struct ib_device *device, if (client->add && !add_client_context(device, client)) client->add(device); device->index = __dev_new_index(); down_write(&lists_rwsem); list_add_tail(&device->core_list, &device_list); up_write(&lists_rwsem); Loading Loading @@ -892,6 +927,31 @@ void ib_enum_all_roce_netdevs(roce_netdev_filter filter, 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 * @device:Device to query Loading Loading @@ -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); static struct ibnl_client_cbs ibnl_ls_cb_table[] = { static const struct rdma_nl_cbs ibnl_ls_cb_table[] = { [RDMA_NL_LS_OP_RESOLVE] = { .dump = ib_nl_handle_resolve_resp, .module = THIS_MODULE }, .doit = ib_nl_handle_resolve_resp, .flags = RDMA_NL_ADMIN_PERM, }, [RDMA_NL_LS_OP_SET_TIMEOUT] = { .dump = ib_nl_handle_set_timeout, .module = THIS_MODULE }, .doit = ib_nl_handle_set_timeout, .flags = RDMA_NL_ADMIN_PERM, }, [RDMA_NL_LS_OP_IP_RESOLVE] = { .dump = ib_nl_handle_ip_res_resp, .module = THIS_MODULE }, .doit = ib_nl_handle_ip_res_resp, .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) { int ret; Loading @@ -1130,9 +1182,9 @@ static int __init ib_core_init(void) goto err_comp; } ret = ibnl_init(); ret = rdma_nl_init(); 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; } Loading @@ -1154,24 +1206,18 @@ static int __init ib_core_init(void) 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); if (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(); return 0; err_ibnl_clients: ib_remove_ibnl_clients(); err_sa: ib_sa_cleanup(); err_mad: Loading @@ -1179,7 +1225,7 @@ static int __init ib_core_init(void) err_addr: addr_cleanup(); err_ibnl: ibnl_cleanup(); rdma_nl_exit(); err_sysfs: class_unregister(&ib_class); err_comp: Loading @@ -1191,13 +1237,14 @@ static int __init ib_core_init(void) static void __exit ib_core_cleanup(void) { unregister_lsm_notifier(&ibdev_lsm_nb); 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_mad_cleanup(); addr_cleanup(); ibnl_cleanup(); rdma_nl_exit(); class_unregister(&ib_class); destroy_workqueue(ib_comp_wq); /* Make sure that any pending umem accounting work is done. */ Loading