Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyverbs: Introducing parent domain #615

Merged
merged 4 commits into from
Nov 25, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pyverbs: Document ParentDomain class and add a simple example
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@mellanox.com>
Reviewed-by: Noa Osherovich <noaos@mellanox.com>
  • Loading branch information
EdwardSro authored and noaos committed Nov 25, 2019
commit 9a932246c8db61aac700264139f6bd9a8b75540e
27 changes: 27 additions & 0 deletions Documentation/pyverbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,30 @@ cai = AddrInfo(server, port, ce.RDMA_PS_TCP)
cid = CMID(creator=cai, qp_init_attr=qp_init_attr)
cid.connect() # send connection request to server
```

##### 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
import pyverbs.mem_alloc as mem


def alloc_p_func(pd, context, size, alignment, resource_type):
p = mem.posix_memalign(size, alignment)
return p


def free_p_func(pd, context, ptr, resource_type):
mem.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)
```