mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-16 01:56:57 +07:00
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: Doug Ledford <dledford@redhat.com>
This commit is contained in:
commit
d0d62c34fb
@ -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
|
||||
|
@ -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))
|
||||
@ -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.
|
||||
@ -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 */
|
||||
|
@ -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)
|
||||
@ -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;
|
||||
@ -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);
|
||||
|
@ -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
|
||||
@ -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
|
||||
@ -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,
|
||||
@ -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 */
|
||||
|
@ -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;
|
||||
@ -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;
|
||||
@ -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';
|
||||
}
|
||||
@ -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
|
||||
@ -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);
|
||||
@ -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
|
||||
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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:
|
||||
@ -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:
|
||||
@ -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. */
|
||||
|
@ -80,7 +80,7 @@ const char *__attribute_const__ iwcm_reject_msg(int reason)
|
||||
}
|
||||
EXPORT_SYMBOL(iwcm_reject_msg);
|
||||
|
||||
static struct ibnl_client_cbs iwcm_nl_cb_table[] = {
|
||||
static struct rdma_nl_cbs iwcm_nl_cb_table[] = {
|
||||
[RDMA_NL_IWPM_REG_PID] = {.dump = iwpm_register_pid_cb},
|
||||
[RDMA_NL_IWPM_ADD_MAPPING] = {.dump = iwpm_add_mapping_cb},
|
||||
[RDMA_NL_IWPM_QUERY_MAPPING] = {.dump = iwpm_add_and_query_mapping_cb},
|
||||
@ -1175,12 +1175,8 @@ static int __init iw_cm_init(void)
|
||||
ret = iwpm_init(RDMA_NL_IWCM);
|
||||
if (ret)
|
||||
pr_err("iw_cm: couldn't init iwpm\n");
|
||||
|
||||
ret = ibnl_add_client(RDMA_NL_IWCM, ARRAY_SIZE(iwcm_nl_cb_table),
|
||||
iwcm_nl_cb_table);
|
||||
if (ret)
|
||||
pr_err("iw_cm: couldn't register netlink callbacks\n");
|
||||
|
||||
else
|
||||
rdma_nl_register(RDMA_NL_IWCM, iwcm_nl_cb_table);
|
||||
iwcm_wq = alloc_ordered_workqueue("iw_cm_wq", WQ_MEM_RECLAIM);
|
||||
if (!iwcm_wq)
|
||||
return -ENOMEM;
|
||||
@ -1200,7 +1196,7 @@ static void __exit iw_cm_cleanup(void)
|
||||
{
|
||||
unregister_net_sysctl_table(iwcm_ctl_table_hdr);
|
||||
destroy_workqueue(iwcm_wq);
|
||||
ibnl_remove_client(RDMA_NL_IWCM);
|
||||
rdma_nl_unregister(RDMA_NL_IWCM);
|
||||
iwpm_exit(RDMA_NL_IWCM);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,6 @@ int iwpm_valid_pid(void)
|
||||
{
|
||||
return iwpm_user_pid > 0;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_valid_pid);
|
||||
|
||||
/*
|
||||
* iwpm_register_pid - Send a netlink query to user space
|
||||
@ -104,7 +103,7 @@ int iwpm_register_pid(struct iwpm_dev_data *pm_msg, u8 nl_client)
|
||||
pr_debug("%s: Multicasting a nlmsg (dev = %s ifname = %s iwpm = %s)\n",
|
||||
__func__, pm_msg->dev_name, pm_msg->if_name, iwpm_ulib_name);
|
||||
|
||||
ret = ibnl_multicast(skb, nlh, RDMA_NL_GROUP_IWPM, GFP_KERNEL);
|
||||
ret = rdma_nl_multicast(skb, RDMA_NL_GROUP_IWPM, GFP_KERNEL);
|
||||
if (ret) {
|
||||
skb = NULL; /* skb is freed in the netlink send-op handling */
|
||||
iwpm_user_pid = IWPM_PID_UNAVAILABLE;
|
||||
@ -122,7 +121,6 @@ int iwpm_register_pid(struct iwpm_dev_data *pm_msg, u8 nl_client)
|
||||
iwpm_free_nlmsg_request(&nlmsg_request->kref);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_register_pid);
|
||||
|
||||
/*
|
||||
* iwpm_add_mapping - Send a netlink add mapping message
|
||||
@ -174,7 +172,7 @@ int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
|
||||
goto add_mapping_error;
|
||||
nlmsg_request->req_buffer = pm_msg;
|
||||
|
||||
ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
|
||||
ret = rdma_nl_unicast_wait(skb, iwpm_user_pid);
|
||||
if (ret) {
|
||||
skb = NULL; /* skb is freed in the netlink send-op handling */
|
||||
iwpm_user_pid = IWPM_PID_UNDEFINED;
|
||||
@ -191,7 +189,6 @@ int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
|
||||
iwpm_free_nlmsg_request(&nlmsg_request->kref);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_add_mapping);
|
||||
|
||||
/*
|
||||
* iwpm_add_and_query_mapping - Send a netlink add and query
|
||||
@ -251,7 +248,7 @@ int iwpm_add_and_query_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
|
||||
goto query_mapping_error;
|
||||
nlmsg_request->req_buffer = pm_msg;
|
||||
|
||||
ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
|
||||
ret = rdma_nl_unicast_wait(skb, iwpm_user_pid);
|
||||
if (ret) {
|
||||
skb = NULL; /* skb is freed in the netlink send-op handling */
|
||||
err_str = "Unable to send a nlmsg";
|
||||
@ -267,7 +264,6 @@ int iwpm_add_and_query_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
|
||||
iwpm_free_nlmsg_request(&nlmsg_request->kref);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_add_and_query_mapping);
|
||||
|
||||
/*
|
||||
* iwpm_remove_mapping - Send a netlink remove mapping message
|
||||
@ -312,7 +308,7 @@ int iwpm_remove_mapping(struct sockaddr_storage *local_addr, u8 nl_client)
|
||||
if (ret)
|
||||
goto remove_mapping_error;
|
||||
|
||||
ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
|
||||
ret = rdma_nl_unicast_wait(skb, iwpm_user_pid);
|
||||
if (ret) {
|
||||
skb = NULL; /* skb is freed in the netlink send-op handling */
|
||||
iwpm_user_pid = IWPM_PID_UNDEFINED;
|
||||
@ -328,7 +324,6 @@ int iwpm_remove_mapping(struct sockaddr_storage *local_addr, u8 nl_client)
|
||||
dev_kfree_skb_any(skb);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_remove_mapping);
|
||||
|
||||
/* netlink attribute policy for the received response to register pid request */
|
||||
static const struct nla_policy resp_reg_policy[IWPM_NLA_RREG_PID_MAX] = {
|
||||
@ -397,7 +392,6 @@ int iwpm_register_pid_cb(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
up(&nlmsg_request->sem);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_register_pid_cb);
|
||||
|
||||
/* netlink attribute policy for the received response to add mapping request */
|
||||
static const struct nla_policy resp_add_policy[IWPM_NLA_RMANAGE_MAPPING_MAX] = {
|
||||
@ -466,7 +460,6 @@ int iwpm_add_mapping_cb(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
up(&nlmsg_request->sem);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_add_mapping_cb);
|
||||
|
||||
/* netlink attribute policy for the response to add and query mapping request
|
||||
* and response with remote address info */
|
||||
@ -558,7 +551,6 @@ int iwpm_add_and_query_mapping_cb(struct sk_buff *skb,
|
||||
up(&nlmsg_request->sem);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_add_and_query_mapping_cb);
|
||||
|
||||
/*
|
||||
* iwpm_remote_info_cb - Process a port mapper message, containing
|
||||
@ -627,7 +619,6 @@ int iwpm_remote_info_cb(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
"remote_info: Mapped remote sockaddr:");
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_remote_info_cb);
|
||||
|
||||
/* netlink attribute policy for the received request for mapping info */
|
||||
static const struct nla_policy resp_mapinfo_policy[IWPM_NLA_MAPINFO_REQ_MAX] = {
|
||||
@ -677,7 +668,6 @@ int iwpm_mapping_info_cb(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
ret = iwpm_send_mapinfo(nl_client, iwpm_user_pid);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_mapping_info_cb);
|
||||
|
||||
/* netlink attribute policy for the received mapping info ack */
|
||||
static const struct nla_policy ack_mapinfo_policy[IWPM_NLA_MAPINFO_NUM_MAX] = {
|
||||
@ -707,7 +697,6 @@ int iwpm_ack_mapping_info_cb(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
atomic_set(&echo_nlmsg_seq, cb->nlh->nlmsg_seq);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_ack_mapping_info_cb);
|
||||
|
||||
/* netlink attribute policy for the received port mapper error message */
|
||||
static const struct nla_policy map_error_policy[IWPM_NLA_ERR_MAX] = {
|
||||
@ -751,4 +740,3 @@ int iwpm_mapping_error_cb(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
up(&nlmsg_request->sem);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_mapping_error_cb);
|
||||
|
@ -54,8 +54,6 @@ static struct iwpm_admin_data iwpm_admin;
|
||||
int iwpm_init(u8 nl_client)
|
||||
{
|
||||
int ret = 0;
|
||||
if (iwpm_valid_client(nl_client))
|
||||
return -EINVAL;
|
||||
mutex_lock(&iwpm_admin_lock);
|
||||
if (atomic_read(&iwpm_admin.refcount) == 0) {
|
||||
iwpm_hash_bucket = kzalloc(IWPM_MAPINFO_HASH_SIZE *
|
||||
@ -83,7 +81,6 @@ int iwpm_init(u8 nl_client)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_init);
|
||||
|
||||
static void free_hash_bucket(void);
|
||||
static void free_reminfo_bucket(void);
|
||||
@ -109,7 +106,6 @@ int iwpm_exit(u8 nl_client)
|
||||
iwpm_set_registration(nl_client, IWPM_REG_UNDEF);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_exit);
|
||||
|
||||
static struct hlist_head *get_mapinfo_hash_bucket(struct sockaddr_storage *,
|
||||
struct sockaddr_storage *);
|
||||
@ -148,7 +144,6 @@ int iwpm_create_mapinfo(struct sockaddr_storage *local_sockaddr,
|
||||
spin_unlock_irqrestore(&iwpm_mapinfo_lock, flags);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_create_mapinfo);
|
||||
|
||||
int iwpm_remove_mapinfo(struct sockaddr_storage *local_sockaddr,
|
||||
struct sockaddr_storage *mapped_local_addr)
|
||||
@ -184,7 +179,6 @@ int iwpm_remove_mapinfo(struct sockaddr_storage *local_sockaddr,
|
||||
spin_unlock_irqrestore(&iwpm_mapinfo_lock, flags);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_remove_mapinfo);
|
||||
|
||||
static void free_hash_bucket(void)
|
||||
{
|
||||
@ -297,7 +291,6 @@ int iwpm_get_remote_info(struct sockaddr_storage *mapped_loc_addr,
|
||||
spin_unlock_irqrestore(&iwpm_reminfo_lock, flags);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(iwpm_get_remote_info);
|
||||
|
||||
struct iwpm_nlmsg_request *iwpm_get_nlmsg_request(__u32 nlmsg_seq,
|
||||
u8 nl_client, gfp_t gfp)
|
||||
@ -383,15 +376,11 @@ int iwpm_get_nlmsg_seq(void)
|
||||
|
||||
int iwpm_valid_client(u8 nl_client)
|
||||
{
|
||||
if (nl_client >= RDMA_NL_NUM_CLIENTS)
|
||||
return 0;
|
||||
return iwpm_admin.client_list[nl_client];
|
||||
}
|
||||
|
||||
void iwpm_set_valid(u8 nl_client, int valid)
|
||||
{
|
||||
if (nl_client >= RDMA_NL_NUM_CLIENTS)
|
||||
return;
|
||||
iwpm_admin.client_list[nl_client] = valid;
|
||||
}
|
||||
|
||||
@ -608,7 +597,7 @@ static int send_mapinfo_num(u32 mapping_num, u8 nl_client, int iwpm_pid)
|
||||
&mapping_num, IWPM_NLA_MAPINFO_SEND_NUM);
|
||||
if (ret)
|
||||
goto mapinfo_num_error;
|
||||
ret = ibnl_unicast(skb, nlh, iwpm_pid);
|
||||
ret = rdma_nl_unicast(skb, iwpm_pid);
|
||||
if (ret) {
|
||||
skb = NULL;
|
||||
err_str = "Unable to send a nlmsg";
|
||||
@ -637,7 +626,7 @@ static int send_nlmsg_done(struct sk_buff *skb, u8 nl_client, int iwpm_pid)
|
||||
return -ENOMEM;
|
||||
}
|
||||
nlh->nlmsg_type = NLMSG_DONE;
|
||||
ret = ibnl_unicast(skb, (struct nlmsghdr *)skb->data, iwpm_pid);
|
||||
ret = rdma_nl_unicast(skb, iwpm_pid);
|
||||
if (ret)
|
||||
pr_warn("%s Unable to send a nlmsg\n", __func__);
|
||||
return ret;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Mellanox Technologies Inc. All rights reserved.
|
||||
* Copyright (c) 2010 Voltaire Inc. All rights reserved.
|
||||
*
|
||||
* This software is available to you under a choice of one of two
|
||||
@ -39,237 +40,253 @@
|
||||
#include <rdma/rdma_netlink.h>
|
||||
#include "core_priv.h"
|
||||
|
||||
struct ibnl_client {
|
||||
struct list_head list;
|
||||
int index;
|
||||
int nops;
|
||||
const struct ibnl_client_cbs *cb_table;
|
||||
};
|
||||
#include "core_priv.h"
|
||||
|
||||
static DEFINE_MUTEX(ibnl_mutex);
|
||||
static DEFINE_MUTEX(rdma_nl_mutex);
|
||||
static struct sock *nls;
|
||||
static LIST_HEAD(client_list);
|
||||
static struct {
|
||||
const struct rdma_nl_cbs *cb_table;
|
||||
} rdma_nl_types[RDMA_NL_NUM_CLIENTS];
|
||||
|
||||
int ibnl_chk_listeners(unsigned int group)
|
||||
int rdma_nl_chk_listeners(unsigned int group)
|
||||
{
|
||||
if (netlink_has_listeners(nls, group) == 0)
|
||||
return -1;
|
||||
return 0;
|
||||
return (netlink_has_listeners(nls, group)) ? 0 : -1;
|
||||
}
|
||||
EXPORT_SYMBOL(rdma_nl_chk_listeners);
|
||||
|
||||
static bool is_nl_msg_valid(unsigned int type, unsigned int op)
|
||||
{
|
||||
static const unsigned int max_num_ops[RDMA_NL_NUM_CLIENTS - 1] = {
|
||||
RDMA_NL_RDMA_CM_NUM_OPS,
|
||||
RDMA_NL_IWPM_NUM_OPS,
|
||||
0,
|
||||
RDMA_NL_LS_NUM_OPS,
|
||||
RDMA_NLDEV_NUM_OPS };
|
||||
|
||||
/*
|
||||
* This BUILD_BUG_ON is intended to catch addition of new
|
||||
* RDMA netlink protocol without updating the array above.
|
||||
*/
|
||||
BUILD_BUG_ON(RDMA_NL_NUM_CLIENTS != 6);
|
||||
|
||||
if (type > RDMA_NL_NUM_CLIENTS - 1)
|
||||
return false;
|
||||
|
||||
return (op < max_num_ops[type - 1]) ? true : false;
|
||||
}
|
||||
|
||||
int ibnl_add_client(int index, int nops,
|
||||
const struct ibnl_client_cbs cb_table[])
|
||||
static bool is_nl_valid(unsigned int type, unsigned int op)
|
||||
{
|
||||
struct ibnl_client *cur;
|
||||
struct ibnl_client *nl_client;
|
||||
const struct rdma_nl_cbs *cb_table;
|
||||
|
||||
nl_client = kmalloc(sizeof *nl_client, GFP_KERNEL);
|
||||
if (!nl_client)
|
||||
return -ENOMEM;
|
||||
if (!is_nl_msg_valid(type, op))
|
||||
return false;
|
||||
|
||||
nl_client->index = index;
|
||||
nl_client->nops = nops;
|
||||
nl_client->cb_table = cb_table;
|
||||
cb_table = rdma_nl_types[type].cb_table;
|
||||
if (!cb_table || (!cb_table[op].dump && !cb_table[op].doit))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
mutex_lock(&ibnl_mutex);
|
||||
|
||||
list_for_each_entry(cur, &client_list, list) {
|
||||
if (cur->index == index) {
|
||||
pr_warn("Client for %d already exists\n", index);
|
||||
mutex_unlock(&ibnl_mutex);
|
||||
kfree(nl_client);
|
||||
return -EINVAL;
|
||||
}
|
||||
void rdma_nl_register(unsigned int index,
|
||||
const struct rdma_nl_cbs cb_table[])
|
||||
{
|
||||
mutex_lock(&rdma_nl_mutex);
|
||||
if (!is_nl_msg_valid(index, 0)) {
|
||||
/*
|
||||
* All clients are not interesting in success/failure of
|
||||
* this call. They want to see the print to error log and
|
||||
* continue their initialization. Print warning for them,
|
||||
* because it is programmer's error to be here.
|
||||
*/
|
||||
mutex_unlock(&rdma_nl_mutex);
|
||||
WARN(true,
|
||||
"The not-valid %u index was supplied to RDMA netlink\n",
|
||||
index);
|
||||
return;
|
||||
}
|
||||
|
||||
list_add_tail(&nl_client->list, &client_list);
|
||||
|
||||
mutex_unlock(&ibnl_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(ibnl_add_client);
|
||||
|
||||
int ibnl_remove_client(int index)
|
||||
{
|
||||
struct ibnl_client *cur, *next;
|
||||
|
||||
mutex_lock(&ibnl_mutex);
|
||||
list_for_each_entry_safe(cur, next, &client_list, list) {
|
||||
if (cur->index == index) {
|
||||
list_del(&(cur->list));
|
||||
mutex_unlock(&ibnl_mutex);
|
||||
kfree(cur);
|
||||
return 0;
|
||||
}
|
||||
if (rdma_nl_types[index].cb_table) {
|
||||
mutex_unlock(&rdma_nl_mutex);
|
||||
WARN(true,
|
||||
"The %u index is already registered in RDMA netlink\n",
|
||||
index);
|
||||
return;
|
||||
}
|
||||
pr_warn("Can't remove callback for client idx %d. Not found\n", index);
|
||||
mutex_unlock(&ibnl_mutex);
|
||||
|
||||
return -EINVAL;
|
||||
rdma_nl_types[index].cb_table = cb_table;
|
||||
mutex_unlock(&rdma_nl_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL(ibnl_remove_client);
|
||||
EXPORT_SYMBOL(rdma_nl_register);
|
||||
|
||||
void rdma_nl_unregister(unsigned int index)
|
||||
{
|
||||
mutex_lock(&rdma_nl_mutex);
|
||||
rdma_nl_types[index].cb_table = NULL;
|
||||
mutex_unlock(&rdma_nl_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL(rdma_nl_unregister);
|
||||
|
||||
void *ibnl_put_msg(struct sk_buff *skb, struct nlmsghdr **nlh, int seq,
|
||||
int len, int client, int op, int flags)
|
||||
{
|
||||
unsigned char *prev_tail;
|
||||
|
||||
prev_tail = skb_tail_pointer(skb);
|
||||
*nlh = nlmsg_put(skb, 0, seq, RDMA_NL_GET_TYPE(client, op),
|
||||
len, flags);
|
||||
*nlh = nlmsg_put(skb, 0, seq, RDMA_NL_GET_TYPE(client, op), len, flags);
|
||||
if (!*nlh)
|
||||
goto out_nlmsg_trim;
|
||||
(*nlh)->nlmsg_len = skb_tail_pointer(skb) - prev_tail;
|
||||
return NULL;
|
||||
return nlmsg_data(*nlh);
|
||||
|
||||
out_nlmsg_trim:
|
||||
nlmsg_trim(skb, prev_tail);
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL(ibnl_put_msg);
|
||||
|
||||
int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
int len, void *data, int type)
|
||||
{
|
||||
unsigned char *prev_tail;
|
||||
|
||||
prev_tail = skb_tail_pointer(skb);
|
||||
if (nla_put(skb, type, len, data))
|
||||
goto nla_put_failure;
|
||||
nlh->nlmsg_len += skb_tail_pointer(skb) - prev_tail;
|
||||
if (nla_put(skb, type, len, data)) {
|
||||
nlmsg_cancel(skb, nlh);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
return 0;
|
||||
|
||||
nla_put_failure:
|
||||
nlmsg_trim(skb, prev_tail - nlh->nlmsg_len);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
EXPORT_SYMBOL(ibnl_put_attr);
|
||||
|
||||
static int ibnl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
struct netlink_ext_ack *extack)
|
||||
static int rdma_nl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct ibnl_client *client;
|
||||
int type = nlh->nlmsg_type;
|
||||
int index = RDMA_NL_GET_CLIENT(type);
|
||||
unsigned int index = RDMA_NL_GET_CLIENT(type);
|
||||
unsigned int op = RDMA_NL_GET_OP(type);
|
||||
const struct rdma_nl_cbs *cb_table;
|
||||
|
||||
list_for_each_entry(client, &client_list, list) {
|
||||
if (client->index == index) {
|
||||
if (op >= client->nops || !client->cb_table[op].dump)
|
||||
return -EINVAL;
|
||||
if (!is_nl_valid(index, op))
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* For response or local service set_timeout request,
|
||||
* there is no need to use netlink_dump_start.
|
||||
*/
|
||||
if (!(nlh->nlmsg_flags & NLM_F_REQUEST) ||
|
||||
(index == RDMA_NL_LS &&
|
||||
op == RDMA_NL_LS_OP_SET_TIMEOUT)) {
|
||||
struct netlink_callback cb = {
|
||||
.skb = skb,
|
||||
.nlh = nlh,
|
||||
.dump = client->cb_table[op].dump,
|
||||
.module = client->cb_table[op].module,
|
||||
};
|
||||
cb_table = rdma_nl_types[index].cb_table;
|
||||
|
||||
return cb.dump(skb, &cb);
|
||||
}
|
||||
if ((cb_table[op].flags & RDMA_NL_ADMIN_PERM) &&
|
||||
!netlink_capable(skb, CAP_NET_ADMIN))
|
||||
return -EPERM;
|
||||
|
||||
{
|
||||
struct netlink_dump_control c = {
|
||||
.dump = client->cb_table[op].dump,
|
||||
.module = client->cb_table[op].module,
|
||||
};
|
||||
return netlink_dump_start(nls, skb, nlh, &c);
|
||||
}
|
||||
}
|
||||
/* FIXME: Convert IWCM to properly handle doit callbacks */
|
||||
if ((nlh->nlmsg_flags & NLM_F_DUMP) || index == RDMA_NL_RDMA_CM ||
|
||||
index == RDMA_NL_IWCM) {
|
||||
struct netlink_dump_control c = {
|
||||
.dump = cb_table[op].dump,
|
||||
};
|
||||
return netlink_dump_start(nls, skb, nlh, &c);
|
||||
}
|
||||
|
||||
pr_info("Index %d wasn't found in client list\n", index);
|
||||
return -EINVAL;
|
||||
if (cb_table[op].doit)
|
||||
return cb_table[op].doit(skb, nlh, extack);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ibnl_rcv_reply_skb(struct sk_buff *skb)
|
||||
/*
|
||||
* This function is similar to netlink_rcv_skb with one exception:
|
||||
* It calls to the callback for the netlink messages without NLM_F_REQUEST
|
||||
* flag. These messages are intended for RDMA_NL_LS consumer, so it is allowed
|
||||
* for that consumer only.
|
||||
*/
|
||||
static int rdma_nl_rcv_skb(struct sk_buff *skb, int (*cb)(struct sk_buff *,
|
||||
struct nlmsghdr *,
|
||||
struct netlink_ext_ack *))
|
||||
{
|
||||
struct netlink_ext_ack extack = {};
|
||||
struct nlmsghdr *nlh;
|
||||
int msglen;
|
||||
int err;
|
||||
|
||||
/*
|
||||
* Process responses until there is no more message or the first
|
||||
* request. Generally speaking, it is not recommended to mix responses
|
||||
* with requests.
|
||||
*/
|
||||
while (skb->len >= nlmsg_total_size(0)) {
|
||||
int msglen;
|
||||
|
||||
nlh = nlmsg_hdr(skb);
|
||||
err = 0;
|
||||
|
||||
if (nlh->nlmsg_len < NLMSG_HDRLEN || skb->len < nlh->nlmsg_len)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
/* Handle response only */
|
||||
if (nlh->nlmsg_flags & NLM_F_REQUEST)
|
||||
return;
|
||||
/*
|
||||
* Generally speaking, the only requests are handled
|
||||
* by the kernel, but RDMA_NL_LS is different, because it
|
||||
* runs backward netlink scheme. Kernel initiates messages
|
||||
* and waits for reply with data to keep pathrecord cache
|
||||
* in sync.
|
||||
*/
|
||||
if (!(nlh->nlmsg_flags & NLM_F_REQUEST) &&
|
||||
(RDMA_NL_GET_CLIENT(nlh->nlmsg_type) != RDMA_NL_LS))
|
||||
goto ack;
|
||||
|
||||
ibnl_rcv_msg(skb, nlh, NULL);
|
||||
/* Skip control messages */
|
||||
if (nlh->nlmsg_type < NLMSG_MIN_TYPE)
|
||||
goto ack;
|
||||
|
||||
err = cb(skb, nlh, &extack);
|
||||
if (err == -EINTR)
|
||||
goto skip;
|
||||
|
||||
ack:
|
||||
if (nlh->nlmsg_flags & NLM_F_ACK || err)
|
||||
netlink_ack(skb, nlh, err, &extack);
|
||||
|
||||
skip:
|
||||
msglen = NLMSG_ALIGN(nlh->nlmsg_len);
|
||||
if (msglen > skb->len)
|
||||
msglen = skb->len;
|
||||
skb_pull(skb, msglen);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ibnl_rcv(struct sk_buff *skb)
|
||||
static void rdma_nl_rcv(struct sk_buff *skb)
|
||||
{
|
||||
mutex_lock(&ibnl_mutex);
|
||||
ibnl_rcv_reply_skb(skb);
|
||||
netlink_rcv_skb(skb, &ibnl_rcv_msg);
|
||||
mutex_unlock(&ibnl_mutex);
|
||||
mutex_lock(&rdma_nl_mutex);
|
||||
rdma_nl_rcv_skb(skb, &rdma_nl_rcv_msg);
|
||||
mutex_unlock(&rdma_nl_mutex);
|
||||
}
|
||||
|
||||
int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
__u32 pid)
|
||||
int rdma_nl_unicast(struct sk_buff *skb, u32 pid)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = netlink_unicast(nls, skb, pid, MSG_DONTWAIT);
|
||||
return (err < 0) ? err : 0;
|
||||
}
|
||||
EXPORT_SYMBOL(rdma_nl_unicast);
|
||||
|
||||
int rdma_nl_unicast_wait(struct sk_buff *skb, __u32 pid)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = netlink_unicast(nls, skb, pid, 0);
|
||||
return (err < 0) ? err : 0;
|
||||
}
|
||||
EXPORT_SYMBOL(ibnl_unicast);
|
||||
EXPORT_SYMBOL(rdma_nl_unicast_wait);
|
||||
|
||||
int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
unsigned int group, gfp_t flags)
|
||||
int rdma_nl_multicast(struct sk_buff *skb, unsigned int group, gfp_t flags)
|
||||
{
|
||||
return nlmsg_multicast(nls, skb, 0, group, flags);
|
||||
}
|
||||
EXPORT_SYMBOL(ibnl_multicast);
|
||||
EXPORT_SYMBOL(rdma_nl_multicast);
|
||||
|
||||
int __init ibnl_init(void)
|
||||
int __init rdma_nl_init(void)
|
||||
{
|
||||
struct netlink_kernel_cfg cfg = {
|
||||
.input = ibnl_rcv,
|
||||
.input = rdma_nl_rcv,
|
||||
};
|
||||
|
||||
nls = netlink_kernel_create(&init_net, NETLINK_RDMA, &cfg);
|
||||
if (!nls) {
|
||||
pr_warn("Failed to create netlink socket\n");
|
||||
if (!nls)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
nls->sk_sndtimeo = 10 * HZ;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ibnl_cleanup(void)
|
||||
void rdma_nl_exit(void)
|
||||
{
|
||||
struct ibnl_client *cur, *next;
|
||||
int idx;
|
||||
|
||||
mutex_lock(&ibnl_mutex);
|
||||
list_for_each_entry_safe(cur, next, &client_list, list) {
|
||||
list_del(&(cur->list));
|
||||
kfree(cur);
|
||||
}
|
||||
mutex_unlock(&ibnl_mutex);
|
||||
for (idx = 0; idx < RDMA_NL_NUM_CLIENTS; idx++)
|
||||
rdma_nl_unregister(idx);
|
||||
|
||||
netlink_kernel_release(nls);
|
||||
}
|
||||
|
322
drivers/infiniband/core/nldev.c
Normal file
322
drivers/infiniband/core/nldev.c
Normal file
@ -0,0 +1,322 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Mellanox Technologies. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the names of the copyright holders nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* Alternatively, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2 as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <net/netlink.h>
|
||||
#include <rdma/rdma_netlink.h>
|
||||
|
||||
#include "core_priv.h"
|
||||
|
||||
static const struct nla_policy nldev_policy[RDMA_NLDEV_ATTR_MAX] = {
|
||||
[RDMA_NLDEV_ATTR_DEV_INDEX] = { .type = NLA_U32 },
|
||||
[RDMA_NLDEV_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING,
|
||||
.len = IB_DEVICE_NAME_MAX - 1},
|
||||
[RDMA_NLDEV_ATTR_PORT_INDEX] = { .type = NLA_U32 },
|
||||
[RDMA_NLDEV_ATTR_FW_VERSION] = { .type = NLA_NUL_STRING,
|
||||
.len = IB_FW_VERSION_NAME_MAX - 1},
|
||||
[RDMA_NLDEV_ATTR_NODE_GUID] = { .type = NLA_U64 },
|
||||
[RDMA_NLDEV_ATTR_SYS_IMAGE_GUID] = { .type = NLA_U64 },
|
||||
[RDMA_NLDEV_ATTR_SUBNET_PREFIX] = { .type = NLA_U64 },
|
||||
[RDMA_NLDEV_ATTR_LID] = { .type = NLA_U32 },
|
||||
[RDMA_NLDEV_ATTR_SM_LID] = { .type = NLA_U32 },
|
||||
[RDMA_NLDEV_ATTR_LMC] = { .type = NLA_U8 },
|
||||
[RDMA_NLDEV_ATTR_PORT_STATE] = { .type = NLA_U8 },
|
||||
[RDMA_NLDEV_ATTR_PORT_PHYS_STATE] = { .type = NLA_U8 },
|
||||
[RDMA_NLDEV_ATTR_DEV_NODE_TYPE] = { .type = NLA_U8 },
|
||||
};
|
||||
|
||||
static int fill_dev_info(struct sk_buff *msg, struct ib_device *device)
|
||||
{
|
||||
char fw[IB_FW_VERSION_NAME_MAX];
|
||||
|
||||
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_DEV_INDEX, device->index))
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_string(msg, RDMA_NLDEV_ATTR_DEV_NAME, device->name))
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, rdma_end_port(device)))
|
||||
return -EMSGSIZE;
|
||||
|
||||
BUILD_BUG_ON(sizeof(device->attrs.device_cap_flags) != sizeof(u64));
|
||||
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_CAP_FLAGS,
|
||||
device->attrs.device_cap_flags, 0))
|
||||
return -EMSGSIZE;
|
||||
|
||||
ib_get_device_fw_str(device, fw);
|
||||
/* Device without FW has strlen(fw) */
|
||||
if (strlen(fw) && nla_put_string(msg, RDMA_NLDEV_ATTR_FW_VERSION, fw))
|
||||
return -EMSGSIZE;
|
||||
|
||||
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_NODE_GUID,
|
||||
be64_to_cpu(device->node_guid), 0))
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_SYS_IMAGE_GUID,
|
||||
be64_to_cpu(device->attrs.sys_image_guid), 0))
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_u8(msg, RDMA_NLDEV_ATTR_DEV_NODE_TYPE, device->node_type))
|
||||
return -EMSGSIZE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fill_port_info(struct sk_buff *msg,
|
||||
struct ib_device *device, u32 port)
|
||||
{
|
||||
struct ib_port_attr attr;
|
||||
int ret;
|
||||
|
||||
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_DEV_INDEX, device->index))
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_string(msg, RDMA_NLDEV_ATTR_DEV_NAME, device->name))
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_PORT_INDEX, port))
|
||||
return -EMSGSIZE;
|
||||
|
||||
ret = ib_query_port(device, port, &attr);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
BUILD_BUG_ON(sizeof(attr.port_cap_flags) > sizeof(u64));
|
||||
if (nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_CAP_FLAGS,
|
||||
(u64)attr.port_cap_flags, 0))
|
||||
return -EMSGSIZE;
|
||||
if (rdma_protocol_ib(device, port) &&
|
||||
nla_put_u64_64bit(msg, RDMA_NLDEV_ATTR_SUBNET_PREFIX,
|
||||
attr.subnet_prefix, 0))
|
||||
return -EMSGSIZE;
|
||||
if (rdma_protocol_ib(device, port)) {
|
||||
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_LID, attr.lid))
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_u32(msg, RDMA_NLDEV_ATTR_SM_LID, attr.sm_lid))
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_u8(msg, RDMA_NLDEV_ATTR_LMC, attr.lmc))
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
if (nla_put_u8(msg, RDMA_NLDEV_ATTR_PORT_STATE, attr.state))
|
||||
return -EMSGSIZE;
|
||||
if (nla_put_u8(msg, RDMA_NLDEV_ATTR_PORT_PHYS_STATE, attr.phys_state))
|
||||
return -EMSGSIZE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nldev_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
|
||||
struct ib_device *device;
|
||||
struct sk_buff *msg;
|
||||
u32 index;
|
||||
int err;
|
||||
|
||||
err = nlmsg_parse(nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
|
||||
nldev_policy, extack);
|
||||
if (err || !tb[RDMA_NLDEV_ATTR_DEV_INDEX])
|
||||
return -EINVAL;
|
||||
|
||||
index = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]);
|
||||
|
||||
device = __ib_device_get_by_index(index);
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
nlh = nlmsg_put(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq,
|
||||
RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_GET),
|
||||
0, 0);
|
||||
|
||||
err = fill_dev_info(msg, device);
|
||||
if (err) {
|
||||
nlmsg_free(msg);
|
||||
return err;
|
||||
}
|
||||
|
||||
nlmsg_end(msg, nlh);
|
||||
|
||||
return rdma_nl_unicast(msg, NETLINK_CB(skb).portid);
|
||||
}
|
||||
|
||||
static int _nldev_get_dumpit(struct ib_device *device,
|
||||
struct sk_buff *skb,
|
||||
struct netlink_callback *cb,
|
||||
unsigned int idx)
|
||||
{
|
||||
int start = cb->args[0];
|
||||
struct nlmsghdr *nlh;
|
||||
|
||||
if (idx < start)
|
||||
return 0;
|
||||
|
||||
nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
|
||||
RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_GET),
|
||||
0, NLM_F_MULTI);
|
||||
|
||||
if (fill_dev_info(skb, device)) {
|
||||
nlmsg_cancel(skb, nlh);
|
||||
goto out;
|
||||
}
|
||||
|
||||
nlmsg_end(skb, nlh);
|
||||
|
||||
idx++;
|
||||
|
||||
out: cb->args[0] = idx;
|
||||
return skb->len;
|
||||
}
|
||||
|
||||
static int nldev_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
|
||||
{
|
||||
/*
|
||||
* There is no need to take lock, because
|
||||
* we are relying on ib_core's lists_rwsem
|
||||
*/
|
||||
return ib_enum_all_devs(_nldev_get_dumpit, skb, cb);
|
||||
}
|
||||
|
||||
static int nldev_port_get_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
|
||||
struct ib_device *device;
|
||||
struct sk_buff *msg;
|
||||
u32 index;
|
||||
u32 port;
|
||||
int err;
|
||||
|
||||
err = nlmsg_parse(nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
|
||||
nldev_policy, extack);
|
||||
if (err || !tb[RDMA_NLDEV_ATTR_PORT_INDEX])
|
||||
return -EINVAL;
|
||||
|
||||
index = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]);
|
||||
device = __ib_device_get_by_index(index);
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
port = nla_get_u32(tb[RDMA_NLDEV_ATTR_PORT_INDEX]);
|
||||
if (!rdma_is_port_valid(device, port))
|
||||
return -EINVAL;
|
||||
|
||||
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
||||
if (!msg)
|
||||
return -ENOMEM;
|
||||
|
||||
nlh = nlmsg_put(msg, NETLINK_CB(skb).portid, nlh->nlmsg_seq,
|
||||
RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_GET),
|
||||
0, 0);
|
||||
|
||||
err = fill_port_info(msg, device, port);
|
||||
if (err) {
|
||||
nlmsg_free(msg);
|
||||
return err;
|
||||
}
|
||||
|
||||
nlmsg_end(msg, nlh);
|
||||
|
||||
return rdma_nl_unicast(msg, NETLINK_CB(skb).portid);
|
||||
}
|
||||
|
||||
static int nldev_port_get_dumpit(struct sk_buff *skb,
|
||||
struct netlink_callback *cb)
|
||||
{
|
||||
struct nlattr *tb[RDMA_NLDEV_ATTR_MAX];
|
||||
struct ib_device *device;
|
||||
int start = cb->args[0];
|
||||
struct nlmsghdr *nlh;
|
||||
u32 idx = 0;
|
||||
u32 ifindex;
|
||||
int err;
|
||||
u32 p;
|
||||
|
||||
err = nlmsg_parse(cb->nlh, 0, tb, RDMA_NLDEV_ATTR_MAX - 1,
|
||||
nldev_policy, NULL);
|
||||
if (err || !tb[RDMA_NLDEV_ATTR_DEV_INDEX])
|
||||
return -EINVAL;
|
||||
|
||||
ifindex = nla_get_u32(tb[RDMA_NLDEV_ATTR_DEV_INDEX]);
|
||||
device = __ib_device_get_by_index(ifindex);
|
||||
if (!device)
|
||||
return -EINVAL;
|
||||
|
||||
for (p = rdma_start_port(device); p <= rdma_end_port(device); ++p) {
|
||||
/*
|
||||
* The dumpit function returns all information from specific
|
||||
* index. This specific index is taken from the netlink
|
||||
* messages request sent by user and it is available
|
||||
* in cb->args[0].
|
||||
*
|
||||
* Usually, the user doesn't fill this field and it causes
|
||||
* to return everything.
|
||||
*
|
||||
*/
|
||||
if (idx < start) {
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
|
||||
nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid,
|
||||
cb->nlh->nlmsg_seq,
|
||||
RDMA_NL_GET_TYPE(RDMA_NL_NLDEV,
|
||||
RDMA_NLDEV_CMD_PORT_GET),
|
||||
0, NLM_F_MULTI);
|
||||
|
||||
if (fill_port_info(skb, device, p)) {
|
||||
nlmsg_cancel(skb, nlh);
|
||||
goto out;
|
||||
}
|
||||
idx++;
|
||||
nlmsg_end(skb, nlh);
|
||||
}
|
||||
|
||||
out: cb->args[0] = idx;
|
||||
return skb->len;
|
||||
}
|
||||
|
||||
static const struct rdma_nl_cbs nldev_cb_table[] = {
|
||||
[RDMA_NLDEV_CMD_GET] = {
|
||||
.doit = nldev_get_doit,
|
||||
.dump = nldev_get_dumpit,
|
||||
},
|
||||
[RDMA_NLDEV_CMD_PORT_GET] = {
|
||||
.doit = nldev_port_get_doit,
|
||||
.dump = nldev_port_get_dumpit,
|
||||
},
|
||||
};
|
||||
|
||||
void __init nldev_init(void)
|
||||
{
|
||||
rdma_nl_register(RDMA_NL_NLDEV, nldev_cb_table);
|
||||
}
|
||||
|
||||
void __exit nldev_exit(void)
|
||||
{
|
||||
rdma_nl_unregister(RDMA_NL_NLDEV);
|
||||
}
|
@ -861,7 +861,7 @@ static int ib_nl_send_msg(struct ib_sa_query *query, gfp_t gfp_mask)
|
||||
/* Repair the nlmsg header length */
|
||||
nlmsg_end(skb, nlh);
|
||||
|
||||
ret = ibnl_multicast(skb, nlh, RDMA_NL_GROUP_LS, gfp_mask);
|
||||
ret = rdma_nl_multicast(skb, RDMA_NL_GROUP_LS, gfp_mask);
|
||||
if (!ret)
|
||||
ret = len;
|
||||
else
|
||||
@ -1021,9 +1021,9 @@ static void ib_nl_request_timeout(struct work_struct *work)
|
||||
}
|
||||
|
||||
int ib_nl_handle_set_timeout(struct sk_buff *skb,
|
||||
struct netlink_callback *cb)
|
||||
struct nlmsghdr *nlh,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
const struct nlmsghdr *nlh = (struct nlmsghdr *)cb->nlh;
|
||||
int timeout, delta, abs_delta;
|
||||
const struct nlattr *attr;
|
||||
unsigned long flags;
|
||||
@ -1033,8 +1033,7 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,
|
||||
int ret;
|
||||
|
||||
if (!(nlh->nlmsg_flags & NLM_F_REQUEST) ||
|
||||
!(NETLINK_CB(skb).sk) ||
|
||||
!netlink_capable(skb, CAP_NET_ADMIN))
|
||||
!(NETLINK_CB(skb).sk))
|
||||
return -EPERM;
|
||||
|
||||
ret = nla_parse(tb, LS_NLA_TYPE_MAX - 1, nlmsg_data(nlh),
|
||||
@ -1098,9 +1097,9 @@ static inline int ib_nl_is_good_resolve_resp(const struct nlmsghdr *nlh)
|
||||
}
|
||||
|
||||
int ib_nl_handle_resolve_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;
|
||||
unsigned long flags;
|
||||
struct ib_sa_query *query;
|
||||
struct ib_mad_send_buf *send_buf;
|
||||
@ -1109,8 +1108,7 @@ int ib_nl_handle_resolve_resp(struct sk_buff *skb,
|
||||
int ret;
|
||||
|
||||
if ((nlh->nlmsg_flags & NLM_F_REQUEST) ||
|
||||
!(NETLINK_CB(skb).sk) ||
|
||||
!netlink_capable(skb, CAP_NET_ADMIN))
|
||||
!(NETLINK_CB(skb).sk))
|
||||
return -EPERM;
|
||||
|
||||
spin_lock_irqsave(&ib_nl_request_lock, flags);
|
||||
@ -1420,7 +1418,7 @@ static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask)
|
||||
|
||||
if ((query->flags & IB_SA_ENABLE_LOCAL_SERVICE) &&
|
||||
(!(query->flags & IB_SA_QUERY_OPA))) {
|
||||
if (!ibnl_chk_listeners(RDMA_NL_GROUP_LS)) {
|
||||
if (!rdma_nl_chk_listeners(RDMA_NL_GROUP_LS)) {
|
||||
if (!ib_nl_make_request(query, gfp_mask))
|
||||
return id;
|
||||
}
|
||||
|
@ -1210,8 +1210,8 @@ static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
|
||||
{
|
||||
struct ib_device *dev = container_of(device, struct ib_device, dev);
|
||||
|
||||
ib_get_device_fw_str(dev, buf, PAGE_SIZE);
|
||||
strlcat(buf, "\n", PAGE_SIZE);
|
||||
ib_get_device_fw_str(dev, buf);
|
||||
strlcat(buf, "\n", IB_FW_VERSION_NAME_MAX);
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
|
@ -1336,8 +1336,7 @@ static int iwch_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void get_dev_fw_ver_str(struct ib_device *ibdev, char *str,
|
||||
size_t str_len)
|
||||
static void get_dev_fw_ver_str(struct ib_device *ibdev, char *str)
|
||||
{
|
||||
struct iwch_dev *iwch_dev = to_iwch_dev(ibdev);
|
||||
struct ethtool_drvinfo info;
|
||||
@ -1345,7 +1344,7 @@ static void get_dev_fw_ver_str(struct ib_device *ibdev, char *str,
|
||||
|
||||
pr_debug("%s dev 0x%p\n", __func__, iwch_dev);
|
||||
lldev->ethtool_ops->get_drvinfo(lldev, &info);
|
||||
snprintf(str, str_len, "%s", info.fw_version);
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%s", info.fw_version);
|
||||
}
|
||||
|
||||
int iwch_register_device(struct iwch_dev *dev)
|
||||
|
@ -517,14 +517,13 @@ static int c4iw_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void get_dev_fw_str(struct ib_device *dev, char *str,
|
||||
size_t str_len)
|
||||
static void get_dev_fw_str(struct ib_device *dev, char *str)
|
||||
{
|
||||
struct c4iw_dev *c4iw_dev = container_of(dev, struct c4iw_dev,
|
||||
ibdev);
|
||||
pr_debug("%s dev 0x%p\n", __func__, dev);
|
||||
|
||||
snprintf(str, str_len, "%u.%u.%u.%u",
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%u.%u.%u.%u",
|
||||
FW_HDR_FW_VER_MAJOR_G(c4iw_dev->rdev.lldi.fw_vers),
|
||||
FW_HDR_FW_VER_MINOR_G(c4iw_dev->rdev.lldi.fw_vers),
|
||||
FW_HDR_FW_VER_MICRO_G(c4iw_dev->rdev.lldi.fw_vers),
|
||||
|
@ -1561,14 +1561,13 @@ static void init_ibport(struct hfi1_pportdata *ppd)
|
||||
RCU_INIT_POINTER(ibp->rvp.qp[1], NULL);
|
||||
}
|
||||
|
||||
static void hfi1_get_dev_fw_str(struct ib_device *ibdev, char *str,
|
||||
size_t str_len)
|
||||
static void hfi1_get_dev_fw_str(struct ib_device *ibdev, char *str)
|
||||
{
|
||||
struct rvt_dev_info *rdi = ib_to_rvt(ibdev);
|
||||
struct hfi1_ibdev *dev = dev_from_rdi(rdi);
|
||||
u32 ver = dd_from_dev(dev)->dc8051_ver;
|
||||
|
||||
snprintf(str, str_len, "%u.%u.%u", dc8051_ver_maj(ver),
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%u.%u.%u", dc8051_ver_maj(ver),
|
||||
dc8051_ver_min(ver), dc8051_ver_patch(ver));
|
||||
}
|
||||
|
||||
|
@ -2584,13 +2584,12 @@ static const char * const i40iw_hw_stat_names[] = {
|
||||
"iwRdmaInv"
|
||||
};
|
||||
|
||||
static void i40iw_get_dev_fw_str(struct ib_device *dev, char *str,
|
||||
size_t str_len)
|
||||
static void i40iw_get_dev_fw_str(struct ib_device *dev, char *str)
|
||||
{
|
||||
u32 firmware_version = I40IW_FW_VERSION;
|
||||
|
||||
snprintf(str, str_len, "%u.%u", firmware_version,
|
||||
(firmware_version & 0x000000ff));
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%u.%u", firmware_version,
|
||||
(firmware_version & 0x000000ff));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2587,12 +2587,11 @@ static int mlx4_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void get_fw_ver_str(struct ib_device *device, char *str,
|
||||
size_t str_len)
|
||||
static void get_fw_ver_str(struct ib_device *device, char *str)
|
||||
{
|
||||
struct mlx4_ib_dev *dev =
|
||||
container_of(device, struct mlx4_ib_dev, ib_dev);
|
||||
snprintf(str, str_len, "%d.%d.%d",
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%d.%d.%d",
|
||||
(int) (dev->dev->caps.fw_ver >> 32),
|
||||
(int) (dev->dev->caps.fw_ver >> 16) & 0xffff,
|
||||
(int) dev->dev->caps.fw_ver & 0xffff);
|
||||
|
@ -3285,13 +3285,13 @@ static int mlx5_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void get_dev_fw_str(struct ib_device *ibdev, char *str,
|
||||
size_t str_len)
|
||||
static void get_dev_fw_str(struct ib_device *ibdev, char *str)
|
||||
{
|
||||
struct mlx5_ib_dev *dev =
|
||||
container_of(ibdev, struct mlx5_ib_dev, ib_dev);
|
||||
snprintf(str, str_len, "%d.%d.%04d", fw_rev_maj(dev->mdev),
|
||||
fw_rev_min(dev->mdev), fw_rev_sub(dev->mdev));
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%d.%d.%04d",
|
||||
fw_rev_maj(dev->mdev), fw_rev_min(dev->mdev),
|
||||
fw_rev_sub(dev->mdev));
|
||||
}
|
||||
|
||||
static int mlx5_eth_lag_init(struct mlx5_ib_dev *dev)
|
||||
|
@ -1178,12 +1178,11 @@ static int mthca_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void get_dev_fw_str(struct ib_device *device, char *str,
|
||||
size_t str_len)
|
||||
static void get_dev_fw_str(struct ib_device *device, char *str)
|
||||
{
|
||||
struct mthca_dev *dev =
|
||||
container_of(device, struct mthca_dev, ib_dev);
|
||||
snprintf(str, str_len, "%d.%d.%d",
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%d.%d.%d",
|
||||
(int) (dev->fw_ver >> 32),
|
||||
(int) (dev->fw_ver >> 16) & 0xffff,
|
||||
(int) dev->fw_ver & 0xffff);
|
||||
|
@ -3672,15 +3672,14 @@ static int nes_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void get_dev_fw_str(struct ib_device *dev, char *str,
|
||||
size_t str_len)
|
||||
static void get_dev_fw_str(struct ib_device *dev, char *str)
|
||||
{
|
||||
struct nes_ib_device *nesibdev =
|
||||
container_of(dev, struct nes_ib_device, ibdev);
|
||||
struct nes_vnic *nesvnic = nesibdev->nesvnic;
|
||||
|
||||
nes_debug(NES_DBG_INIT, "\n");
|
||||
snprintf(str, str_len, "%u.%u",
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%u.%u",
|
||||
(nesvnic->nesdev->nesadapter->firmware_version >> 16),
|
||||
(nesvnic->nesdev->nesadapter->firmware_version & 0x000000ff));
|
||||
}
|
||||
|
@ -107,12 +107,11 @@ static int ocrdma_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void get_dev_fw_str(struct ib_device *device, char *str,
|
||||
size_t str_len)
|
||||
static void get_dev_fw_str(struct ib_device *device, char *str)
|
||||
{
|
||||
struct ocrdma_dev *dev = get_ocrdma_dev(device);
|
||||
|
||||
snprintf(str, str_len, "%s", &dev->attr.fw_ver[0]);
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%s", &dev->attr.fw_ver[0]);
|
||||
}
|
||||
|
||||
static int ocrdma_register_device(struct ocrdma_dev *dev)
|
||||
|
@ -68,13 +68,12 @@ static enum rdma_link_layer qedr_link_layer(struct ib_device *device,
|
||||
return IB_LINK_LAYER_ETHERNET;
|
||||
}
|
||||
|
||||
static void qedr_get_dev_fw_str(struct ib_device *ibdev, char *str,
|
||||
size_t str_len)
|
||||
static void qedr_get_dev_fw_str(struct ib_device *ibdev, char *str)
|
||||
{
|
||||
struct qedr_dev *qedr = get_qedr_dev(ibdev);
|
||||
u32 fw_ver = (u32)qedr->attr.fw_ver;
|
||||
|
||||
snprintf(str, str_len, "%d. %d. %d. %d",
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%d. %d. %d. %d",
|
||||
(fw_ver >> 24) & 0xFF, (fw_ver >> 16) & 0xFF,
|
||||
(fw_ver >> 8) & 0xFF, fw_ver & 0xFF);
|
||||
}
|
||||
|
@ -333,9 +333,7 @@ static int usnic_port_immutable(struct ib_device *ibdev, u8 port_num,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void usnic_get_dev_fw_str(struct ib_device *device,
|
||||
char *str,
|
||||
size_t str_len)
|
||||
static void usnic_get_dev_fw_str(struct ib_device *device, char *str)
|
||||
{
|
||||
struct usnic_ib_dev *us_ibdev =
|
||||
container_of(device, struct usnic_ib_dev, ib_dev);
|
||||
@ -345,7 +343,7 @@ static void usnic_get_dev_fw_str(struct ib_device *device,
|
||||
us_ibdev->netdev->ethtool_ops->get_drvinfo(us_ibdev->netdev, &info);
|
||||
mutex_unlock(&us_ibdev->usdev_lock);
|
||||
|
||||
snprintf(str, str_len, "%s", info.fw_version);
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%s", info.fw_version);
|
||||
}
|
||||
|
||||
/* Start of PF discovery section */
|
||||
|
@ -102,12 +102,11 @@ static struct device_attribute *pvrdma_class_attributes[] = {
|
||||
&dev_attr_board_id
|
||||
};
|
||||
|
||||
static void pvrdma_get_fw_ver_str(struct ib_device *device, char *str,
|
||||
size_t str_len)
|
||||
static void pvrdma_get_fw_ver_str(struct ib_device *device, char *str)
|
||||
{
|
||||
struct pvrdma_dev *dev =
|
||||
container_of(device, struct pvrdma_dev, ib_dev);
|
||||
snprintf(str, str_len, "%d.%d.%d\n",
|
||||
snprintf(str, IB_FW_VERSION_NAME_MAX, "%d.%d.%d\n",
|
||||
(int) (dev->dsr->caps.fw_ver >> 32),
|
||||
(int) (dev->dsr->caps.fw_ver >> 16) & 0xffff,
|
||||
(int) dev->dsr->caps.fw_ver & 0xffff);
|
||||
|
@ -62,8 +62,7 @@ static void ipoib_get_drvinfo(struct net_device *netdev,
|
||||
{
|
||||
struct ipoib_dev_priv *priv = ipoib_priv(netdev);
|
||||
|
||||
ib_get_device_fw_str(priv->ca, drvinfo->fw_version,
|
||||
sizeof(drvinfo->fw_version));
|
||||
ib_get_device_fw_str(priv->ca, drvinfo->fw_version);
|
||||
|
||||
strlcpy(drvinfo->bus_info, dev_name(priv->ca->dev.parent),
|
||||
sizeof(drvinfo->bus_info));
|
||||
|
@ -64,6 +64,8 @@
|
||||
#include <linux/cgroup_rdma.h>
|
||||
#include <uapi/rdma/ib_user_verbs.h>
|
||||
|
||||
#define IB_FW_VERSION_NAME_MAX ETHTOOL_FWVERS_LEN
|
||||
|
||||
extern struct workqueue_struct *ib_wq;
|
||||
extern struct workqueue_struct *ib_comp_wq;
|
||||
|
||||
@ -2298,6 +2300,8 @@ struct ib_device {
|
||||
struct rdmacg_device cg_device;
|
||||
#endif
|
||||
|
||||
u32 index;
|
||||
|
||||
/**
|
||||
* The following mandatory functions are used only at device
|
||||
* registration. Keep functions such as these at the end of this
|
||||
@ -2305,7 +2309,7 @@ struct ib_device {
|
||||
* in fast paths.
|
||||
*/
|
||||
int (*get_port_immutable)(struct ib_device *, u8, struct ib_port_immutable *);
|
||||
void (*get_dev_fw_str)(struct ib_device *, char *str, size_t str_len);
|
||||
void (*get_dev_fw_str)(struct ib_device *, char *str);
|
||||
const struct cpumask *(*get_vector_affinity)(struct ib_device *ibdev,
|
||||
int comp_vector);
|
||||
};
|
||||
@ -2343,7 +2347,7 @@ struct ib_client {
|
||||
struct ib_device *ib_alloc_device(size_t size);
|
||||
void ib_dealloc_device(struct ib_device *device);
|
||||
|
||||
void ib_get_device_fw_str(struct ib_device *device, char *str, size_t str_len);
|
||||
void ib_get_device_fw_str(struct ib_device *device, char *str);
|
||||
|
||||
int ib_register_device(struct ib_device *device,
|
||||
int (*port_callback)(struct ib_device *,
|
||||
|
@ -5,29 +5,31 @@
|
||||
#include <linux/netlink.h>
|
||||
#include <uapi/rdma/rdma_netlink.h>
|
||||
|
||||
struct ibnl_client_cbs {
|
||||
struct rdma_nl_cbs {
|
||||
int (*doit)(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
struct netlink_ext_ack *extack);
|
||||
int (*dump)(struct sk_buff *skb, struct netlink_callback *nlcb);
|
||||
struct module *module;
|
||||
u8 flags;
|
||||
};
|
||||
|
||||
enum rdma_nl_flags {
|
||||
/* Require CAP_NET_ADMIN */
|
||||
RDMA_NL_ADMIN_PERM = 1 << 0,
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a a client to the list of IB netlink exporters.
|
||||
* Register client in RDMA netlink.
|
||||
* @index: Index of the added client
|
||||
* @nops: Number of supported ops by the added client.
|
||||
* @cb_table: A table for op->callback
|
||||
*
|
||||
* Returns 0 on success or a negative error code.
|
||||
*/
|
||||
int ibnl_add_client(int index, int nops,
|
||||
const struct ibnl_client_cbs cb_table[]);
|
||||
void rdma_nl_register(unsigned int index,
|
||||
const struct rdma_nl_cbs cb_table[]);
|
||||
|
||||
/**
|
||||
* Remove a client from IB netlink.
|
||||
* @index: Index of the removed IB client.
|
||||
*
|
||||
* Returns 0 on success or a negative error code.
|
||||
*/
|
||||
int ibnl_remove_client(int index);
|
||||
void rdma_nl_unregister(unsigned int index);
|
||||
|
||||
/**
|
||||
* Put a new message in a supplied skb.
|
||||
@ -56,22 +58,32 @@ int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
/**
|
||||
* Send the supplied skb to a specific userspace PID.
|
||||
* @skb: The netlink skb
|
||||
* @nlh: Header of the netlink message to send
|
||||
* @pid: Userspace netlink process ID
|
||||
* Returns 0 on success or a negative error code.
|
||||
*/
|
||||
int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
__u32 pid);
|
||||
int rdma_nl_unicast(struct sk_buff *skb, u32 pid);
|
||||
|
||||
/**
|
||||
* Send, with wait/1 retry, the supplied skb to a specific userspace PID.
|
||||
* @skb: The netlink skb
|
||||
* @pid: Userspace netlink process ID
|
||||
* Returns 0 on success or a negative error code.
|
||||
*/
|
||||
int rdma_nl_unicast_wait(struct sk_buff *skb, __u32 pid);
|
||||
|
||||
/**
|
||||
* Send the supplied skb to a netlink group.
|
||||
* @skb: The netlink skb
|
||||
* @nlh: Header of the netlink message to send
|
||||
* @group: Netlink group ID
|
||||
* @flags: allocation flags
|
||||
* Returns 0 on success or a negative error code.
|
||||
*/
|
||||
int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
unsigned int group, gfp_t flags);
|
||||
int rdma_nl_multicast(struct sk_buff *skb, unsigned int group, gfp_t flags);
|
||||
|
||||
/**
|
||||
* Check if there are any listeners to the netlink group
|
||||
* @group: the netlink group ID
|
||||
* Returns 0 on success or a negative for no listeners.
|
||||
*/
|
||||
int rdma_nl_chk_listeners(unsigned int group);
|
||||
#endif /* _RDMA_NETLINK_H */
|
||||
|
@ -8,7 +8,7 @@ enum {
|
||||
RDMA_NL_IWCM,
|
||||
RDMA_NL_RSVD,
|
||||
RDMA_NL_LS, /* RDMA Local Services */
|
||||
RDMA_NL_I40IW,
|
||||
RDMA_NL_NLDEV, /* RDMA device interface */
|
||||
RDMA_NL_NUM_CLIENTS
|
||||
};
|
||||
|
||||
@ -222,4 +222,86 @@ struct rdma_nla_ls_gid {
|
||||
__u8 gid[16];
|
||||
};
|
||||
|
||||
enum rdma_nldev_command {
|
||||
RDMA_NLDEV_CMD_UNSPEC,
|
||||
|
||||
RDMA_NLDEV_CMD_GET, /* can dump */
|
||||
RDMA_NLDEV_CMD_SET,
|
||||
RDMA_NLDEV_CMD_NEW,
|
||||
RDMA_NLDEV_CMD_DEL,
|
||||
|
||||
RDMA_NLDEV_CMD_PORT_GET, /* can dump */
|
||||
RDMA_NLDEV_CMD_PORT_SET,
|
||||
RDMA_NLDEV_CMD_PORT_NEW,
|
||||
RDMA_NLDEV_CMD_PORT_DEL,
|
||||
|
||||
RDMA_NLDEV_NUM_OPS
|
||||
};
|
||||
|
||||
enum rdma_nldev_attr {
|
||||
/* don't change the order or add anything between, this is ABI! */
|
||||
RDMA_NLDEV_ATTR_UNSPEC,
|
||||
|
||||
/* Identifier for ib_device */
|
||||
RDMA_NLDEV_ATTR_DEV_INDEX, /* u32 */
|
||||
|
||||
RDMA_NLDEV_ATTR_DEV_NAME, /* string */
|
||||
/*
|
||||
* Device index together with port index are identifiers
|
||||
* for port/link properties.
|
||||
*
|
||||
* For RDMA_NLDEV_CMD_GET commamnd, port index will return number
|
||||
* of available ports in ib_device, while for port specific operations,
|
||||
* it will be real port index as it appears in sysfs. Port index follows
|
||||
* sysfs notation and starts from 1 for the first port.
|
||||
*/
|
||||
RDMA_NLDEV_ATTR_PORT_INDEX, /* u32 */
|
||||
|
||||
/*
|
||||
* Device and port capabilities
|
||||
*/
|
||||
RDMA_NLDEV_ATTR_CAP_FLAGS, /* u64 */
|
||||
|
||||
/*
|
||||
* FW version
|
||||
*/
|
||||
RDMA_NLDEV_ATTR_FW_VERSION, /* string */
|
||||
|
||||
/*
|
||||
* Node GUID (in host byte order) associated with the RDMA device.
|
||||
*/
|
||||
RDMA_NLDEV_ATTR_NODE_GUID, /* u64 */
|
||||
|
||||
/*
|
||||
* System image GUID (in host byte order) associated with
|
||||
* this RDMA device and other devices which are part of a
|
||||
* single system.
|
||||
*/
|
||||
RDMA_NLDEV_ATTR_SYS_IMAGE_GUID, /* u64 */
|
||||
|
||||
/*
|
||||
* Subnet prefix (in host byte order)
|
||||
*/
|
||||
RDMA_NLDEV_ATTR_SUBNET_PREFIX, /* u64 */
|
||||
|
||||
/*
|
||||
* Local Identifier (LID),
|
||||
* According to IB specification, It is 16-bit address assigned
|
||||
* by the Subnet Manager. Extended to be 32-bit for OmniPath users.
|
||||
*/
|
||||
RDMA_NLDEV_ATTR_LID, /* u32 */
|
||||
RDMA_NLDEV_ATTR_SM_LID, /* u32 */
|
||||
|
||||
/*
|
||||
* LID mask control (LMC)
|
||||
*/
|
||||
RDMA_NLDEV_ATTR_LMC, /* u8 */
|
||||
|
||||
RDMA_NLDEV_ATTR_PORT_STATE, /* u8 */
|
||||
RDMA_NLDEV_ATTR_PORT_PHYS_STATE, /* u8 */
|
||||
|
||||
RDMA_NLDEV_ATTR_DEV_NODE_TYPE, /* u8 */
|
||||
|
||||
RDMA_NLDEV_ATTR_MAX
|
||||
};
|
||||
#endif /* _UAPI_RDMA_NETLINK_H */
|
||||
|
Loading…
Reference in New Issue
Block a user