@@ -164,12 +164,12 @@ device must be opened prior to creation and a PD has to be allocated.
164164import pyverbs.device as d
165165from pyverbs.pd import PD
166166from pyverbs.mr import MR
167- import pyverbs.enums as e
167+ from pyverbs.libibverbs_enums import ibv_access_flags
168168
169169with d.Context(name = ' mlx5_0' ) as ctx:
170170 with PD(ctx) as pd:
171171 mr_len = 1000
172- flags = e .IBV_ACCESS_LOCAL_WRITE
172+ flags = ibv_access_flags .IBV_ACCESS_LOCAL_WRITE
173173 mr = MR(pd, mr_len, flags)
174174```
175175##### Memory window
@@ -181,11 +181,11 @@ deregister an MR that the MW is bound to.
181181import pyverbs.device as d
182182from pyverbs.pd import PD
183183from pyverbs.mr import MW
184- import pyverbs.enums as e
184+ from pyverbs.libibverbs_enums import ibv_mw_type
185185
186186with d.Context(name = ' mlx5_0' ) as ctx:
187187 with PD(ctx) as pd:
188- mw = MW(pd, e .IBV_MW_TYPE_1 )
188+ mw = MW(pd, ibv_mw_type .IBV_MW_TYPE_1 )
189189```
190190##### Device memory
191191The following snippet shows how to allocate a DM - a direct memory object,
@@ -214,7 +214,7 @@ from pyverbs.device import DM, AllocDmAttr
214214from pyverbs.mr import DMMR
215215import pyverbs.device as d
216216from pyverbs.pd import PD
217- import pyverbs.enums as e
217+ from pyverbs.libibverbs_enums import ibv_access_flags
218218
219219with d.Context(name = ' mlx5_0' ) as ctx:
220220 attr = ctx.query_device_ex()
@@ -224,7 +224,7 @@ with d.Context(name='mlx5_0') as ctx:
224224 dm_mr_len = random.randint(4 , dm_len)
225225 with DM(ctx, dm_attrs) as dm:
226226 with PD(ctx) as pd:
227- dm_mr = DMMR(pd, dm_mr_len, e .IBV_ACCESS_ZERO_BASED , dm = dm,
227+ dm_mr = DMMR(pd, dm_mr_len, ibv_access_flags .IBV_ACCESS_ZERO_BASED , dm = dm,
228228 offset = 0 )
229229```
230230
@@ -262,11 +262,11 @@ import random
262262
263263from pyverbs.cq import CqInitAttrEx, CQEX
264264import pyverbs.device as d
265- import pyverbs.enums as e
265+ from pyverbs.libibverbs_enums import ibv_create_cq_wc_flags
266266
267267with d.Context(name = ' mlx5_0' ) as ctx:
268268 num_cqe = random.randint(0 , 200 )
269- wc_flags = e .IBV_WC_EX_WITH_CVLAN
269+ wc_flags = ibv_create_cq_wc_flags .IBV_WC_EX_WITH_CVLAN
270270 comp_mask = 0 # Not using flags in this example
271271 # completion channel is not used in this example
272272 attrs = CqInitAttrEx(cqe = num_cqe, wc_flags = wc_flags, comp_mask = comp_mask,
@@ -318,7 +318,7 @@ from pyverbs.qp import QPCap, QPInitAttr, QPAttr, QP
318318from pyverbs.addr import GlobalRoute
319319from pyverbs.addr import AH , AHAttr
320320import pyverbs.device as d
321- import pyverbs.enums as e
321+ from pyverbs.libibverbs_enums import ibv_qp_type
322322from pyverbs.pd import PD
323323from pyverbs.cq import CQ
324324import pyverbs.wr as pwr
@@ -328,7 +328,7 @@ ctx = d.Context(name='mlx5_0')
328328pd = PD(ctx)
329329cq = CQ(ctx, 100 , None , None , 0 )
330330cap = QPCap(100 , 10 , 1 , 1 , 0 )
331- qia = QPInitAttr(cap = cap, qp_type = e .IBV_QPT_UD , scq = cq, rcq = cq)
331+ qia = QPInitAttr(cap = cap, qp_type = ibv_qp_type .IBV_QPT_UD , scq = cq, rcq = cq)
332332# A UD QP will be in RTS if a QPAttr object is provided
333333udqp = QP(pd, qia, QPAttr())
334334port_num = 1
@@ -351,7 +351,7 @@ when using the extended QP's new post send mechanism.
351351``` python
352352from pyverbs.qp import QPCap, QPInitAttrEx, QPAttr, QPEx
353353import pyverbs.device as d
354- import pyverbs.enums as e
354+ from pyverbs.libibverbs_enums import ibv_qp_type, ibv_qp_init_attr_mask
355355from pyverbs.pd import PD
356356from pyverbs.cq import CQ
357357
@@ -360,9 +360,9 @@ ctx = d.Context(name='mlx5_0')
360360pd = PD(ctx)
361361cq = CQ(ctx, 100 )
362362cap = QPCap(100 , 10 , 1 , 1 , 0 )
363- qia = QPInitAttrEx(qp_type = e .IBV_QPT_UD , scq = cq, rcq = cq, cap = cap, pd = pd,
364- comp_mask = e .IBV_QP_INIT_ATTR_SEND_OPS_FLAGS | \
365- e .IBV_QP_INIT_ATTR_PD )
363+ qia = QPInitAttrEx(qp_type = ibv_qp_type .IBV_QPT_UD , scq = cq, rcq = cq, cap = cap, pd = pd,
364+ comp_mask = ibv_qp_init_attr_mask .IBV_QP_INIT_ATTR_SEND_OPS_FLAGS | \
365+ ibv_qp_init_attr_mask .IBV_QP_INIT_ATTR_PD )
366366qp = QPEx(ctx, qia)
367367```
368368
@@ -371,15 +371,15 @@ The following code demonstrates creation of an XRCD object.
371371``` python
372372from pyverbs.xrcd import XRCD , XRCDInitAttr
373373import pyverbs.device as d
374- import pyverbs.enums as e
374+ from pyverbs.libibverbs_enums import ibv_xrcd_init_attr_mask
375375import stat
376376import os
377377
378378
379379ctx = d.Context(name = ' ibp0s8f0' )
380380xrcd_fd = os.open(' /tmp/xrcd' , os.O_RDONLY | os.O_CREAT ,
381381 stat.S_IRUSR | stat.S_IRGRP )
382- init = XRCDInitAttr(e .IBV_XRCD_INIT_ATTR_FD | e .IBV_XRCD_INIT_ATTR_OFLAGS ,
382+ init = XRCDInitAttr(ibv_xrcd_init_attr_mask .IBV_XRCD_INIT_ATTR_FD | ibv_xrcd_init_attr_mask .IBV_XRCD_INIT_ATTR_OFLAGS ,
383383 os.O_CREAT , xrcd_fd)
384384xrcd = XRCD(ctx, init)
385385```
@@ -391,7 +391,7 @@ For more complex examples, please see pyverbs/tests/test_odp.
391391from pyverbs.xrcd import XRCD , XRCDInitAttr
392392from pyverbs.srq import SRQ , SrqInitAttrEx
393393import pyverbs.device as d
394- import pyverbs.enums as e
394+ from pyverbs.libibverbs_enums import ibv_xrcd_init_attr_mask, ibv_srq_type, ibv_srq_init_attr_mask
395395from pyverbs.cq import CQ
396396from pyverbs.pd import PD
397397import stat
@@ -403,17 +403,17 @@ pd = PD(ctx)
403403cq = CQ(ctx, 100 , None , None , 0 )
404404xrcd_fd = os.open(' /tmp/xrcd' , os.O_RDONLY | os.O_CREAT ,
405405 stat.S_IRUSR | stat.S_IRGRP )
406- init = XRCDInitAttr(e .IBV_XRCD_INIT_ATTR_FD | e .IBV_XRCD_INIT_ATTR_OFLAGS ,
406+ init = XRCDInitAttr(ibv_xrcd_init_attr_mask .IBV_XRCD_INIT_ATTR_FD | ibv_xrcd_init_attr_mask .IBV_XRCD_INIT_ATTR_OFLAGS ,
407407 os.O_CREAT , xrcd_fd)
408408xrcd = XRCD(ctx, init)
409409
410410srq_attr = SrqInitAttrEx(max_wr = 10 )
411- srq_attr.srq_type = e .IBV_SRQT_XRC
411+ srq_attr.srq_type = ibv_srq_type .IBV_SRQT_XRC
412412srq_attr.pd = pd
413413srq_attr.xrcd = xrcd
414414srq_attr.cq = cq
415- srq_attr.comp_mask = e .IBV_SRQ_INIT_ATTR_TYPE | e .IBV_SRQ_INIT_ATTR_PD | \
416- e .IBV_SRQ_INIT_ATTR_CQ | e .IBV_SRQ_INIT_ATTR_XRCD
415+ srq_attr.comp_mask = ibv_srq_init_attr_mask .IBV_SRQ_INIT_ATTR_TYPE | ibv_srq_init_attr_mask .IBV_SRQ_INIT_ATTR_PD | \
416+ ibv_srq_init_attr_mask .IBV_SRQ_INIT_ATTR_CQ | ibv_srq_init_attr_mask .IBV_SRQ_INIT_ATTR_XRCD
417417srq = SRQ(ctx, srq_attr)
418418```
419419
@@ -476,9 +476,9 @@ following PRs.
476476``` python
477477from pyverbs.providers.mlx5.mlx5dv import Mlx5Context, Mlx5DVContextAttr
478478from pyverbs.providers.mlx5.mlx5dv import Mlx5DVQPInitAttr, Mlx5QP
479- import pyverbs.providers.mlx5.mlx5_enums as me
479+ from pyverbs.providers.mlx5.mlx5_enums import mlx5dv_qp_init_attr_mask, mlx5dv_dc_type, mlx5dv_qp_create_flags
480480from pyverbs.qp import QPInitAttrEx, QPCap
481- import pyverbs.enums as e
481+ from pyverbs.libibverbs_enums import ibv_qp_type, ibv_qp_init_attr_mask, ibv_qp_type
482482from pyverbs.cq import CQ
483483from pyverbs.pd import PD
484484
@@ -487,19 +487,19 @@ with Mlx5Context(name='rocep0s8f0', attr=Mlx5DVContextAttr()) as ctx:
487487 with CQ(ctx, 100 ) as cq:
488488 cap = QPCap(100 , 0 , 1 , 0 )
489489 # Create a DC QP of type DCI
490- qia = QPInitAttrEx(cap = cap, pd = pd, scq = cq, qp_type = e .IBV_QPT_DRIVER ,
491- comp_mask = e .IBV_QP_INIT_ATTR_PD , rcq = cq)
492- attr = Mlx5DVQPInitAttr(comp_mask = me .MLX5DV_QP_INIT_ATTR_MASK_DC )
493- attr.dc_type = me .MLX5DV_DCTYPE_DCI
490+ qia = QPInitAttrEx(cap = cap, pd = pd, scq = cq, qp_type = ibv_qp_type .IBV_QPT_DRIVER ,
491+ comp_mask = ibv_qp_init_attr_mask .IBV_QP_INIT_ATTR_PD , rcq = cq)
492+ attr = Mlx5DVQPInitAttr(comp_mask = mlx5dv_qp_init_attr_mask .MLX5DV_QP_INIT_ATTR_MASK_DC )
493+ attr.dc_type = mlx5dv_dc_type .MLX5DV_DCTYPE_DCI
494494
495495 dci = Mlx5QP(ctx, qia, dv_init_attr = attr)
496496
497497 # Create a Raw Packet QP using mlx5-specific capabilities
498- qia.qp_type = e .IBV_QPT_RAW_PACKET
499- attr.comp_mask = me .MLX5DV_QP_INIT_ATTR_MASK_QP_CREATE_FLAGS
500- attr.create_flags = me .MLX5DV_QP_CREATE_ALLOW_SCATTER_TO_CQE | \
501- me .MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_UC | \
502- me .MLX5DV_QP_CREATE_TUNNEL_OFFLOADS
498+ qia.qp_type = ibv_qp_type .IBV_QPT_RAW_PACKET
499+ attr.comp_mask = mlx5dv_qp_init_attr_mask .MLX5DV_QP_INIT_ATTR_MASK_QP_CREATE_FLAGS
500+ attr.create_flags = mlx5dv_qp_create_flags .MLX5DV_QP_CREATE_ALLOW_SCATTER_TO_CQE | \
501+ mlx5dv_qp_create_flags .MLX5DV_QP_CREATE_TIR_ALLOW_SELF_LOOPBACK_UC | \
502+ mlx5dv_qp_create_flags .MLX5DV_QP_CREATE_TUNNEL_OFFLOADS
503503 qp = Mlx5QP(ctx, qia, dv_init_attr = attr)
504504```
505505
@@ -512,13 +512,13 @@ The following snippet shows this simple creation process.
512512``` python
513513from pyverbs.providers.mlx5.mlx5dv import Mlx5Context, Mlx5DVContextAttr
514514from pyverbs.providers.mlx5.mlx5dv import Mlx5DVCQInitAttr, Mlx5CQ
515- import pyverbs.providers.mlx5.mlx5_enums as me
515+ from pyverbs.providers.mlx5.mlx5_enums import mlx5dv_cq_init_attr_mask, mlx5dv_cqe_comp_res_format
516516from pyverbs.cq import CqInitAttrEx
517517
518518with Mlx5Context(name = ' rocep0s8f0' , attr = Mlx5DVContextAttr()) as ctx:
519519 cqia = CqInitAttrEx()
520- mlx5_cqia = Mlx5DVCQInitAttr(comp_mask = me .MLX5DV_CQ_INIT_ATTR_MASK_COMPRESSED_CQE ,
521- cqe_comp_res_format = me .MLX5DV_CQE_RES_FORMAT_CSUM )
520+ mlx5_cqia = Mlx5DVCQInitAttr(comp_mask = mlx5dv_cq_init_attr_mask .MLX5DV_CQ_INIT_ATTR_MASK_COMPRESSED_CQE ,
521+ cqe_comp_res_format = mlx5dv_cqe_comp_res_format .MLX5DV_CQE_RES_FORMAT_CSUM )
522522 cq = Mlx5CQ(ctx, cqia, dv_init_attr = mlx5_cqia)
523523```
524524
@@ -530,8 +530,7 @@ For more complex examples, please see tests/test_rdmacm.
530530``` python
531531from pyverbs.qp import QPInitAttr, QPCap
532532from pyverbs.cmid import CMID , AddrInfo
533- import pyverbs.cm_enums as ce
534-
533+ from pyverbs.librdmacm_enums import rdma_port_space, RAI_PASSIVE
535534
536535cap = QPCap(max_recv_wr = 1 )
537536qp_init_attr = QPInitAttr(cap = cap)
@@ -540,15 +539,15 @@ port = '7471'
540539
541540# Passive side
542541
543- sai = AddrInfo(src = addr, src_service = port, port_space = ce .RDMA_PS_TCP , flags = ce. RAI_PASSIVE )
542+ sai = AddrInfo(src = addr, src_service = port, port_space = rdma_port_space .RDMA_PS_TCP , flags = RAI_PASSIVE )
544543sid = CMID(creator = sai, qp_init_attr = qp_init_attr)
545544sid.listen() # listen for incoming connection requests
546545new_id = sid.get_request() # check if there are any connection requests
547546new_id.accept() # new_id is connected to remote peer and ready to communicate
548547
549548# Active side
550549
551- cai = AddrInfo(src = addr, dst = addr, dst_service = port, port_space = ce .RDMA_PS_TCP )
550+ cai = AddrInfo(src = addr, dst = addr, dst_service = port, port_space = rdma_port_space .RDMA_PS_TCP )
552551cid = CMID(creator = cai, qp_init_attr = qp_init_attr)
553552cid.connect() # send connection request to passive addr
554553```
@@ -604,10 +603,10 @@ The following code snippet demonstrates how to allocate an mlx5dv_pp with rate
604603limit value of 5, then frees the entry.
605604``` python
606605from pyverbs.providers.mlx5.mlx5dv import Mlx5Context, Mlx5DVContextAttr, Mlx5PP
607- import pyverbs.providers.mlx5.mlx5_enums as e
606+ from pyverbs.providers.mlx5.mlx5_enums import mlx5dv_context_attr_flags
608607
609608# The device must be opened as DEVX context
610- mlx5dv_attr = Mlx5DVContextAttr(e .MLX5DV_CONTEXT_FLAGS_DEVX )
609+ mlx5dv_attr = Mlx5DVContextAttr(mlx5dv_context_attr_flags .MLX5DV_CONTEXT_FLAGS_DEVX )
611610ctx = Mlx5Context(attr = mlx5dv_attr, name = ' rocep0s8f0' )
612611rate_limit_inbox = (5 ).to_bytes(length = 4 , byteorder = ' big' , signed = True )
613612pp = Mlx5PP(ctx, rate_limit_inbox)
@@ -650,18 +649,18 @@ Here is a demonstration of importing a device, PD and MR in one process.
650649from pyverbs.device import Context
651650from pyverbs.pd import PD
652651from pyverbs.mr import MR
653- import pyverbs.enums as e
652+ from pyverbs.libibverbs_enums import ibv_access_flags
654653import os
655654
656655ctx = Context(name = ' ibp0s8f0' )
657656pd = PD(ctx)
658- mr = MR(pd, 100 , e .IBV_ACCESS_LOCAL_WRITE )
657+ mr = MR(pd, 100 , ibv_access_flags .IBV_ACCESS_LOCAL_WRITE )
659658cmd_fd_dup = os.dup(ctx.cmd_fd)
660659imported_ctx = Context(cmd_fd = cmd_fd_dup)
661660imported_pd = PD(imported_ctx, handle = pd.handle)
662661imported_mr = MR(imported_pd, handle = mr.handle)
663662# MRs can be created as usual on the imported PD
664- secondary_mr = MR(imported_pd, 100 , e .IBV_ACCESS_REMOTE_READ )
663+ secondary_mr = MR(imported_pd, 100 , ibv_access_flags .IBV_ACCESS_REMOTE_READ )
665664# Must manually unimport the imported objects (which close the object and frees
666665# other resources that use them) before closing the "original" objects.
667666# This prevents unexpected behaviours caused by the GC.
@@ -683,7 +682,7 @@ from pyverbs.qp import QPCap, QPInitAttr, QPAttr, QP
683682from pyverbs.flow import FlowAttr, Flow
684683from pyverbs.spec import EthSpec
685684import pyverbs.device as d
686- import pyverbs.enums as e
685+ from pyverbs.libibverbs_enums import ibv_qp_type
687686from pyverbs.pd import PD
688687from pyverbs.cq import CQ
689688
@@ -692,7 +691,7 @@ ctx = d.Context(name='rocep0s8f0')
692691pd = PD(ctx)
693692cq = CQ(ctx, 100 , None , None , 0 )
694693cap = QPCap(100 , 10 , 1 , 1 , 0 )
695- qia = QPInitAttr(cap = cap, qp_type = e .IBV_QPT_UD , scq = cq, rcq = cq)
694+ qia = QPInitAttr(cap = cap, qp_type = ibv_qp_type .IBV_QPT_UD , scq = cq, rcq = cq)
696695qp = QP(pd, qia, QPAttr())
697696
698697# Create Eth spec
0 commit comments