/** * ib_cleanup_ucaps - cleanup all API resources and class. * * This is called once, when removing the ib_uverbs module.
*/ void ib_cleanup_ucaps(void)
{
mutex_lock(&ucaps_mutex); if (!ucaps_class_is_registered) {
mutex_unlock(&ucaps_mutex); return;
}
for (int i = RDMA_UCAP_FIRST; i < RDMA_UCAP_MAX; i++)
WARN_ON(ucaps_list[i]);
/** * ib_ucaps_init - Initialization required before ucap creation. * * Return: 0 on success, or a negative errno value on failure
*/ staticint ib_ucaps_init(void)
{ int ret = 0;
if (ucaps_class_is_registered) return ret;
ret = class_register(&ucaps_class); if (ret) return ret;
ret = alloc_chrdev_region(&ucaps_base_dev, 0, RDMA_UCAP_MAX,
ucaps_class.name); if (ret < 0) {
class_unregister(&ucaps_class); return ret;
}
/** * ib_create_ucap - Add a ucap character device * @type: UCAP type * * Creates a ucap character device in the /dev/infiniband directory. By default, * the device has root-only read-write access. * * A driver may call this multiple times with the same UCAP type. A reference * count tracks creations and deletions. * * Return: 0 on success, or a negative errno value on failure
*/ int ib_create_ucap(enum rdma_user_cap type)
{ struct ib_ucap *ucap; int ret;
if (type >= RDMA_UCAP_MAX) return -EINVAL;
mutex_lock(&ucaps_mutex);
ret = ib_ucaps_init(); if (ret) goto unlock;
/** * ib_remove_ucap - Remove a ucap character device * @type: User cap type * * Removes the ucap character device according to type. The device is completely * removed from the filesystem when its reference count reaches 0.
*/ void ib_remove_ucap(enum rdma_user_cap type)
{ struct ib_ucap *ucap;
mutex_lock(&ucaps_mutex);
ucap = ucaps_list[type]; if (WARN_ON(!ucap)) goto end;
/** * ib_get_ucaps - Get bitmask of ucap types from file descriptors * @fds: Array of file descriptors * @fd_count: Number of file descriptors in the array * @idx_mask: Bitmask to be updated based on the ucaps in the fd list * * Given an array of file descriptors, this function returns a bitmask of * the ucaps where a bit is set if an FD for that ucap type was in the array. * * Return: 0 on success, or a negative errno value on failure
*/ int ib_get_ucaps(int *fds, int fd_count, uint64_t *idx_mask)
{ int ret = 0;
dev_t dev;
*idx_mask = 0;
mutex_lock(&ucaps_mutex); for (int i = 0; i < fd_count; i++) {
ret = get_devt_from_fd(fds[i], &dev); if (ret) goto end;
ret = get_ucap_from_devt(dev, idx_mask); if (ret) goto end;
}
end:
mutex_unlock(&ucaps_mutex); return ret;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.19 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.