History

RDMA/uverbs: Add CQ buffer UMEM attribute and driver helpers

Add UVERBS_ATTR_CREATE_CQ_BUF_UMEM and two driver-facing wrappers, ib_umem_get_cq_buf() and ib_umem_get_cq_buf_or_va(), that pin a CQ buffer umem from it. The wrappers reuse the existing legacy CQ buffer-attr filler.

Jiri Pirko committed 5 months ago

Commit f6d2e531 parent 057bb704 files · +79 −1Browse files

Unified · Split

4 files
  1. drivers/infiniband/core/umem.c +56 −1
  2. drivers/infiniband/core/uverbs_std_types_cq.c +2 −0
  3. include/rdma/ib_umem.h +20 −0
  4. include/uapi/rdma/ib_user_ioctl_cmds.h +1 −0
drivers/infiniband/core/umem.c+56−1
@@ -497,7 +497,7 @@ struct ib_umem *ib_umem_get_attr_or_va(struct ib_device *device, · 496 unmodified lines
497}497}
498EXPORT_SYMBOL(ib_umem_get_attr_or_va);498EXPORT_SYMBOL(ib_umem_get_attr_or_va);
499 499
500static int uverbs_create_cq_get_buffer_desc(struct uverbs_attr_bundle *attrs,500static int uverbs_create_cq_get_buffer_desc(const struct uverbs_attr_bundle *attrs,
501 struct ib_uverbs_buffer_desc *desc)501 struct ib_uverbs_buffer_desc *desc)
502{502{
503 struct ib_device *ib_dev = attrs->context->device;503 struct ib_device *ib_dev = attrs->context->device;
@@ -547,6 +547,61 @@ static int uverbs_create_cq_get_buffer_desc(struct uverbs_attr_bundle *attrs, · 43 unmodified lines
547 return -ENODATA;547 return -ENODATA;
548}548}
549 549
550/**
551 * ib_umem_get_cq_buf - Pin a CQ buffer umem from per-command attributes.
552 * @device: IB device.
553 * @attrs: uverbs attribute bundle (may be NULL).
554 * @size: minimum required CQ buffer length.
555 * @access: IB access flags.
556 *
557 * Resolves the CQ buffer from the new UMEM attribute or the legacy
558 * CQ buffer attributes. There is no UHW VA fallback, so the caller
559 * must arrange its own backing (typically an in-kernel allocation)
560 * when no source is available.
561 *
562 * Return: caller-owned umem on success; NULL when no source supplied
563 * a buffer; ERR_PTR(...) on error.
564 */
565struct ib_umem *ib_umem_get_cq_buf(struct ib_device *device,
566 const struct uverbs_attr_bundle *attrs,
567 size_t size, int access)
568{
569 return ib_umem_get_from_attrs(device, attrs,
570 UVERBS_ATTR_CREATE_CQ_BUF_UMEM,
571 uverbs_create_cq_get_buffer_desc,
572 size, access);
573}
574EXPORT_SYMBOL(ib_umem_get_cq_buf);
575
576/**
577 * ib_umem_get_cq_buf_or_va - Pin a CQ buffer umem with UHW VA fallback.
578 * @device: IB device.
579 * @attrs: uverbs attribute bundle (may be NULL).
580 * @addr: UHW user VA used when no per-command attribute matched.
581 * @size: on the attr / legacy paths, the minimum required umem length
582 * validated post-pin; on the VA fallback path, the length to pin.
583 * @access: IB access flags.
584 *
585 * Like ib_umem_get_cq_buf(), but pins @addr/@size when neither the
586 * UMEM attribute nor the legacy CQ buffer attributes are supplied.
587 *
588 * See ib_umem_get_attr_or_va() for the note on @size's dual role and
589 * the migration path for drivers that would distinguish a user-supplied
590 * length from a driver-computed minimum.
591 *
592 * Return: caller-owned umem on success, ERR_PTR(...) on error.
593 */
594struct ib_umem *ib_umem_get_cq_buf_or_va(struct ib_device *device,
595 const struct uverbs_attr_bundle *attrs,
596 u64 addr, size_t size, int access)
597{
598 return ib_umem_get_from_attrs_or_va(device, attrs,
599 UVERBS_ATTR_CREATE_CQ_BUF_UMEM,
600 uverbs_create_cq_get_buffer_desc,
601 addr, size, access);
602}
603EXPORT_SYMBOL(ib_umem_get_cq_buf_or_va);
604
550/**605/**
551 * ib_umem_get_cq_tmp - Temporary CQ buffer umem getter.606 * ib_umem_get_cq_tmp - Temporary CQ buffer umem getter.
552 * @device: IB device.607 * @device: IB device.
drivers/infiniband/core/uverbs_std_types_cq.c+2−0
@@ -215,6 +215,8 @@ DECLARE_UVERBS_NAMED_METHOD( · 214 unmodified lines
215 UVERBS_ATTR_PTR_IN(UVERBS_ATTR_CREATE_CQ_BUFFER_OFFSET,215 UVERBS_ATTR_PTR_IN(UVERBS_ATTR_CREATE_CQ_BUFFER_OFFSET,
216 UVERBS_ATTR_TYPE(u64),216 UVERBS_ATTR_TYPE(u64),
217 UA_OPTIONAL),217 UA_OPTIONAL),
218 UVERBS_ATTR_UMEM(UVERBS_ATTR_CREATE_CQ_BUF_UMEM,
219 UA_OPTIONAL),
218 UVERBS_ATTR_UHW());220 UVERBS_ATTR_UHW());
219 221
220static int UVERBS_HANDLER(UVERBS_METHOD_CQ_DESTROY)(222static int UVERBS_HANDLER(UVERBS_METHOD_CQ_DESTROY)(
include/rdma/ib_umem.h+20−0
@@ -90,6 +90,12 @@ struct ib_umem *ib_umem_get_attr_or_va(struct ib_device *device, · 89 unmodified lines
90 const struct uverbs_attr_bundle *attrs,90 const struct uverbs_attr_bundle *attrs,
91 u16 attr_id, u64 addr, size_t size,91 u16 attr_id, u64 addr, size_t size,
92 int access);92 int access);
93struct ib_umem *ib_umem_get_cq_buf(struct ib_device *device,
94 const struct uverbs_attr_bundle *attrs,
95 size_t size, int access);
96struct ib_umem *ib_umem_get_cq_buf_or_va(struct ib_device *device,
97 const struct uverbs_attr_bundle *attrs,
98 u64 addr, size_t size, int access);
93struct ib_umem *ib_umem_get_cq_tmp(struct ib_device *device,99struct ib_umem *ib_umem_get_cq_tmp(struct ib_device *device,
94 struct uverbs_attr_bundle *attrs);100 struct uverbs_attr_bundle *attrs);
95 101
@@ -210,6 +216,20 @@ ib_umem_get_attr_or_va(struct ib_device *device, · 114 unmodified lines
210 return ERR_PTR(-EOPNOTSUPP);216 return ERR_PTR(-EOPNOTSUPP);
211}217}
212static inline struct ib_umem *218static inline struct ib_umem *
219ib_umem_get_cq_buf(struct ib_device *device,
220 const struct uverbs_attr_bundle *attrs, size_t size,
221 int access)
222{
223 return ERR_PTR(-EOPNOTSUPP);
224}
225static inline struct ib_umem *
226ib_umem_get_cq_buf_or_va(struct ib_device *device,
227 const struct uverbs_attr_bundle *attrs, u64 addr,
228 size_t size, int access)
229{
230 return ERR_PTR(-EOPNOTSUPP);
231}
232static inline struct ib_umem *
213ib_umem_get_cq_tmp(struct ib_device *device, struct uverbs_attr_bundle *attrs)233ib_umem_get_cq_tmp(struct ib_device *device, struct uverbs_attr_bundle *attrs)
214{234{
215 return ERR_PTR(-EOPNOTSUPP);235 return ERR_PTR(-EOPNOTSUPP);
include/uapi/rdma/ib_user_ioctl_cmds.h+1−0
@@ -117,6 +117,7 @@ enum uverbs_attrs_create_cq_cmd_attr_ids { · 116 unmodified lines
117 UVERBS_ATTR_CREATE_CQ_BUFFER_LENGTH,117 UVERBS_ATTR_CREATE_CQ_BUFFER_LENGTH,
118 UVERBS_ATTR_CREATE_CQ_BUFFER_FD,118 UVERBS_ATTR_CREATE_CQ_BUFFER_FD,
119 UVERBS_ATTR_CREATE_CQ_BUFFER_OFFSET,119 UVERBS_ATTR_CREATE_CQ_BUFFER_OFFSET,
120 UVERBS_ATTR_CREATE_CQ_BUF_UMEM,
120};121};
121 122
122enum uverbs_attrs_destroy_cq_cmd_attr_ids {123enum uverbs_attrs_destroy_cq_cmd_attr_ids {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t