@@ -164,12 +164,12 @@ device must be opened prior to creation and a PD has to be allocated.
164
164
import pyverbs.device as d
165
165
from pyverbs.pd import PD
166
166
from pyverbs.mr import MR
167
- import pyverbs.enums as e
167
+ from pyverbs.libibverbs_enums import ibv_access_flags
168
168
169
169
with d.Context(name = ' mlx5_0' ) as ctx:
170
170
with PD(ctx) as pd:
171
171
mr_len = 1000
172
- flags = e .IBV_ACCESS_LOCAL_WRITE
172
+ flags = ibv_access_flags .IBV_ACCESS_LOCAL_WRITE
173
173
mr = MR(pd, mr_len, flags)
174
174
```
175
175
##### Memory window
@@ -181,11 +181,11 @@ deregister an MR that the MW is bound to.
181
181
import pyverbs.device as d
182
182
from pyverbs.pd import PD
183
183
from pyverbs.mr import MW
184
- import pyverbs.enums as e
184
+ from pyverbs.libibverbs_enums import ibv_mw_type
185
185
186
186
with d.Context(name = ' mlx5_0' ) as ctx:
187
187
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 )
189
189
```
190
190
##### Device memory
191
191
The following snippet shows how to allocate a DM - a direct memory object,
@@ -214,7 +214,7 @@ from pyverbs.device import DM, AllocDmAttr
214
214
from pyverbs.mr import DMMR
215
215
import pyverbs.device as d
216
216
from pyverbs.pd import PD
217
- import pyverbs.enums as e
217
+ from pyverbs.libibverbs_enums import ibv_access_flags
218
218
219
219
with d.Context(name = ' mlx5_0' ) as ctx:
220
220
attr = ctx.query_device_ex()
@@ -224,7 +224,7 @@ with d.Context(name='mlx5_0') as ctx:
224
224
dm_mr_len = random.randint(4 , dm_len)
225
225
with DM(ctx, dm_attrs) as dm:
226
226
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,
228
228
offset = 0 )
229
229
```
230
230
@@ -262,11 +262,11 @@ import random
262
262
263
263
from pyverbs.cq import CqInitAttrEx, CQEX
264
264
import pyverbs.device as d
265
- import pyverbs.enums as e
265
+ from pyverbs.libibverbs_enums import ibv_create_cq_wc_flags
266
266
267
267
with d.Context(name = ' mlx5_0' ) as ctx:
268
268
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
270
270
comp_mask = 0 # Not using flags in this example
271
271
# completion channel is not used in this example
272
272
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
318
318
from pyverbs.addr import GlobalRoute
319
319
from pyverbs.addr import AH , AHAttr
320
320
import pyverbs.device as d
321
- import pyverbs.enums as e
321
+ from pyverbs.libibverbs_enums import ibv_qp_type
322
322
from pyverbs.pd import PD
323
323
from pyverbs.cq import CQ
324
324
import pyverbs.wr as pwr
@@ -328,7 +328,7 @@ ctx = d.Context(name='mlx5_0')
328
328
pd = PD(ctx)
329
329
cq = CQ(ctx, 100 , None , None , 0 )
330
330
cap = 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)
332
332
# A UD QP will be in RTS if a QPAttr object is provided
333
333
udqp = QP(pd, qia, QPAttr())
334
334
port_num = 1
@@ -351,7 +351,7 @@ when using the extended QP's new post send mechanism.
351
351
``` python
352
352
from pyverbs.qp import QPCap, QPInitAttrEx, QPAttr, QPEx
353
353
import pyverbs.device as d
354
- import pyverbs.enums as e
354
+ from pyverbs.libibverbs_enums import ibv_qp_type, ibv_qp_init_attr_mask
355
355
from pyverbs.pd import PD
356
356
from pyverbs.cq import CQ
357
357
@@ -360,9 +360,9 @@ ctx = d.Context(name='mlx5_0')
360
360
pd = PD(ctx)
361
361
cq = CQ(ctx, 100 )
362
362
cap = 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 )
366
366
qp = QPEx(ctx, qia)
367
367
```
368
368
@@ -371,15 +371,15 @@ The following code demonstrates creation of an XRCD object.
371
371
``` python
372
372
from pyverbs.xrcd import XRCD , XRCDInitAttr
373
373
import pyverbs.device as d
374
- import pyverbs.enums as e
374
+ from pyverbs.libibverbs_enums import ibv_xrcd_init_attr_mask
375
375
import stat
376
376
import os
377
377
378
378
379
379
ctx = d.Context(name = ' ibp0s8f0' )
380
380
xrcd_fd = os.open(' /tmp/xrcd' , os.O_RDONLY | os.O_CREAT ,
381
381
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 ,
383
383
os.O_CREAT , xrcd_fd)
384
384
xrcd = XRCD(ctx, init)
385
385
```
@@ -391,7 +391,7 @@ For more complex examples, please see pyverbs/tests/test_odp.
391
391
from pyverbs.xrcd import XRCD , XRCDInitAttr
392
392
from pyverbs.srq import SRQ , SrqInitAttrEx
393
393
import 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
395
395
from pyverbs.cq import CQ
396
396
from pyverbs.pd import PD
397
397
import stat
@@ -403,17 +403,17 @@ pd = PD(ctx)
403
403
cq = CQ(ctx, 100 , None , None , 0 )
404
404
xrcd_fd = os.open(' /tmp/xrcd' , os.O_RDONLY | os.O_CREAT ,
405
405
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 ,
407
407
os.O_CREAT , xrcd_fd)
408
408
xrcd = XRCD(ctx, init)
409
409
410
410
srq_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
412
412
srq_attr.pd = pd
413
413
srq_attr.xrcd = xrcd
414
414
srq_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
417
417
srq = SRQ(ctx, srq_attr)
418
418
```
419
419
@@ -476,9 +476,9 @@ following PRs.
476
476
``` python
477
477
from pyverbs.providers.mlx5.mlx5dv import Mlx5Context, Mlx5DVContextAttr
478
478
from 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
480
480
from 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
482
482
from pyverbs.cq import CQ
483
483
from pyverbs.pd import PD
484
484
@@ -487,19 +487,19 @@ with Mlx5Context(name='rocep0s8f0', attr=Mlx5DVContextAttr()) as ctx:
487
487
with CQ(ctx, 100 ) as cq:
488
488
cap = QPCap(100 , 0 , 1 , 0 )
489
489
# 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
494
494
495
495
dci = Mlx5QP(ctx, qia, dv_init_attr = attr)
496
496
497
497
# 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
503
503
qp = Mlx5QP(ctx, qia, dv_init_attr = attr)
504
504
```
505
505
@@ -512,13 +512,13 @@ The following snippet shows this simple creation process.
512
512
``` python
513
513
from pyverbs.providers.mlx5.mlx5dv import Mlx5Context, Mlx5DVContextAttr
514
514
from 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
516
516
from pyverbs.cq import CqInitAttrEx
517
517
518
518
with Mlx5Context(name = ' rocep0s8f0' , attr = Mlx5DVContextAttr()) as ctx:
519
519
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 )
522
522
cq = Mlx5CQ(ctx, cqia, dv_init_attr = mlx5_cqia)
523
523
```
524
524
@@ -530,8 +530,7 @@ For more complex examples, please see tests/test_rdmacm.
530
530
``` python
531
531
from pyverbs.qp import QPInitAttr, QPCap
532
532
from pyverbs.cmid import CMID , AddrInfo
533
- import pyverbs.cm_enums as ce
534
-
533
+ from pyverbs.librdmacm_enums import rdma_port_space, RAI_PASSIVE
535
534
536
535
cap = QPCap(max_recv_wr = 1 )
537
536
qp_init_attr = QPInitAttr(cap = cap)
@@ -540,15 +539,15 @@ port = '7471'
540
539
541
540
# Passive side
542
541
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 )
544
543
sid = CMID(creator = sai, qp_init_attr = qp_init_attr)
545
544
sid.listen() # listen for incoming connection requests
546
545
new_id = sid.get_request() # check if there are any connection requests
547
546
new_id.accept() # new_id is connected to remote peer and ready to communicate
548
547
549
548
# Active side
550
549
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 )
552
551
cid = CMID(creator = cai, qp_init_attr = qp_init_attr)
553
552
cid.connect() # send connection request to passive addr
554
553
```
@@ -604,10 +603,10 @@ The following code snippet demonstrates how to allocate an mlx5dv_pp with rate
604
603
limit value of 5, then frees the entry.
605
604
``` python
606
605
from 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
608
607
609
608
# 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 )
611
610
ctx = Mlx5Context(attr = mlx5dv_attr, name = ' rocep0s8f0' )
612
611
rate_limit_inbox = (5 ).to_bytes(length = 4 , byteorder = ' big' , signed = True )
613
612
pp = Mlx5PP(ctx, rate_limit_inbox)
@@ -650,18 +649,18 @@ Here is a demonstration of importing a device, PD and MR in one process.
650
649
from pyverbs.device import Context
651
650
from pyverbs.pd import PD
652
651
from pyverbs.mr import MR
653
- import pyverbs.enums as e
652
+ from pyverbs.libibverbs_enums import ibv_access_flags
654
653
import os
655
654
656
655
ctx = Context(name = ' ibp0s8f0' )
657
656
pd = PD(ctx)
658
- mr = MR(pd, 100 , e .IBV_ACCESS_LOCAL_WRITE )
657
+ mr = MR(pd, 100 , ibv_access_flags .IBV_ACCESS_LOCAL_WRITE )
659
658
cmd_fd_dup = os.dup(ctx.cmd_fd)
660
659
imported_ctx = Context(cmd_fd = cmd_fd_dup)
661
660
imported_pd = PD(imported_ctx, handle = pd.handle)
662
661
imported_mr = MR(imported_pd, handle = mr.handle)
663
662
# 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 )
665
664
# Must manually unimport the imported objects (which close the object and frees
666
665
# other resources that use them) before closing the "original" objects.
667
666
# This prevents unexpected behaviours caused by the GC.
@@ -683,7 +682,7 @@ from pyverbs.qp import QPCap, QPInitAttr, QPAttr, QP
683
682
from pyverbs.flow import FlowAttr, Flow
684
683
from pyverbs.spec import EthSpec
685
684
import pyverbs.device as d
686
- import pyverbs.enums as e
685
+ from pyverbs.libibverbs_enums import ibv_qp_type
687
686
from pyverbs.pd import PD
688
687
from pyverbs.cq import CQ
689
688
@@ -692,7 +691,7 @@ ctx = d.Context(name='rocep0s8f0')
692
691
pd = PD(ctx)
693
692
cq = CQ(ctx, 100 , None , None , 0 )
694
693
cap = 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)
696
695
qp = QP(pd, qia, QPAttr())
697
696
698
697
# Create Eth spec
0 commit comments