Add code snippet to show AH creation. Fix a typo in DMMR snippet. Signed-off-by: Noa Osherovich <noaos@xxxxxxxxxxxx> --- Documentation/pyverbs.md | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/Documentation/pyverbs.md b/Documentation/pyverbs.md index 3a20b7a95769..371fcd07b2cd 100644 --- a/Documentation/pyverbs.md +++ b/Documentation/pyverbs.md @@ -209,7 +209,7 @@ device's own memory rather than a user-allocated buffer. import random from pyverbs.device import DM, AllocDmAttr -from pyverbs.mr import DmMr +from pyverbs.mr import DMMR import pyverbs.device as d from pyverbs.pd import PD import pyverbs.enums as e @@ -222,7 +222,7 @@ with d.Context(name='mlx5_0') as ctx: dm_mr_len = random.randint(4, dm_len) with DM(ctx, dm_attrs) as dm: with PD(ctx) as pd: - dm_mr = DmMr(pd, dm_mr_len, e.IBV_ACCESS_ZERO_BASED, dm=dm, + dm_mr = DMMR(pd, dm_mr_len, e.IBV_ACCESS_ZERO_BASED, dm=dm, offset=0) ``` @@ -280,4 +280,30 @@ flags : 0 Extended CQ: Handle : 0 CQEs : 15 -``` \ No newline at end of file +``` + +##### Addressing related objects +The following code demonstrates creation of GlobalRoute, AHAttr and AH objects. +The example creates a global AH so it can also run on RoCE without +modifications. +```python + +from pyverbs.addr import GlobalRoute, AHAttr, AH +import pyverbs.device as d +from pyverbs.pd import PD + +with d.Context(name='mlx5_0') as ctx: + port_number = 1 + gid_index = 0 # GID index 0 always exists and valid + gid = ctx.query_gid(port_number, gid_index) + gr = GlobalRoute(dgid=gid, sgid_index=gid_index) + ah_attr = AHAttr(gr=gr, is_global=1, port_num=port_number) + print(ah_attr) + with PD(ctx) as pd: + ah = AH(pd, attr=ah_attr) +DGID : fe80:0000:0000:0000:9a03:9bff:fe00:e4bf +flow label : 0 +sgid index : 0 +hop limit : 1 +traffic class : 0 +``` -- 2.17.2