From: Edward Srouji <edwards@xxxxxxxxxxxx> Add a documentation for ParentDomain with a simple code snippet demonstrating the creation of the object with Python defined allocators. Signed-off-by: Edward Srouji <edwards@xxxxxxxxxxxx> Reviewd-by: Noa Osherovich <noaos@xxxxxxxxxxxx> --- Documentation/pyverbs.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Documentation/pyverbs.md b/Documentation/pyverbs.md index 29ab9592c53c..db6c6b99905e 100755 --- a/Documentation/pyverbs.md +++ b/Documentation/pyverbs.md @@ -390,3 +390,30 @@ srq_attr.comp_mask = e.IBV_SRQ_INIT_ATTR_TYPE | e.IBV_SRQ_INIT_ATTR_PD | \ e.IBV_SRQ_INIT_ATTR_CQ | e.IBV_SRQ_INIT_ATTR_XRCD srq = SRQ(ctx, srq_attr) ``` + +##### ParentDomain +The following code demonstrates the creation of Parent Domain object. +In this example, a simple Python allocator is defined. It uses MemAlloc class to +allocate aligned memory using a C style aligned_alloc. +```python +from pyverbs.pd import PD, ParentDomainInitAttr, ParentDomain, \ + ParentDomainContext +from pyverbs.device import Context +from pyverbs.base import MemAlloc + + +def alloc_p_func(pd, context, size, alignment, resource_type): + p = MemAlloc.aligned_alloc(size, alignment) + return p + + +def free_p_func(pd, context, ptr, resource_type): + MemAlloc.free(ptr) + + +ctx = Context(name='rocep0s8f0') +pd = PD(ctx) +pd_ctx = ParentDomainContext(pd, alloc_p_func, free_p_func) +pd_attr = ParentDomainInitAttr(pd=pd, pd_context=pd_ctx) +parent_domain = ParentDomain(ctx, attr=pd_attr) +``` -- 2.21.0