Skip to content

Commit

Permalink
pyverbs: Support dr destination TIR action creation
Browse files Browse the repository at this point in the history
Support creation of DR destination TIR action.

Signed-off-by: Shachar Kagan <skagan@nvidia.com>
Signed-off-by: Edward Srouji <edwards@nvidia.com>
  • Loading branch information
ShacharKagan authored and EdwardSro committed Feb 23, 2022
1 parent 9459b91 commit f50a9c7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pyverbs/providers/mlx5/dr_action.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ cdef class DrActionVPort(DrAction):
cdef class DrActionIBPort(DrAction):
cdef DrDomain domain
cdef int ib_port

cdef class DrActionDestTir(DrAction):
cdef Mlx5DevxObj devx_obj
13 changes: 13 additions & 0 deletions pyverbs/providers/mlx5/dr_action.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,16 @@ cdef class DrActionIBPort(DrAction):
if self.action != NULL:
super(DrActionIBPort, self).close()
self.domain = None

cdef class DrActionDestTir(DrAction):
def __init__(self, Mlx5DevxObj devx_tir):
"""
Create DR dest devx tir action.
:param devx_tir: Destination Mlx5DevxObj tir.
"""
super().__init__()
self.action = dv.mlx5dv_dr_action_create_dest_devx_tir(devx_tir.obj)
if self.action == NULL:
raise PyverbsRDMAErrno('Failed to create TIR action')
self.devx_obj = devx_tir
devx_tir.add_ref(self)
1 change: 1 addition & 0 deletions pyverbs/providers/mlx5/libmlx5.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ cdef extern from 'infiniband/mlx5dv.h':
v.ibv_device **mlx5dv_get_vfio_device_list(mlx5dv_vfio_context_attr *attr)
int mlx5dv_vfio_get_events_fd(v.ibv_context *ibctx)
int mlx5dv_vfio_process_events(v.ibv_context *context)
mlx5dv_dr_action *mlx5dv_dr_action_create_dest_devx_tir(mlx5dv_devx_obj *devx_obj)

# DevX APIs
mlx5dv_devx_uar *mlx5dv_devx_alloc_uar(v.ibv_context *context, uint32_t flags)
Expand Down
1 change: 1 addition & 0 deletions pyverbs/providers/mlx5/mlx5dv.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ cdef class Mlx5DevxObj(PyverbsCM):
cdef Context context
cdef object out_view
cdef object flow_counter_actions
cdef object dest_tir_actions
cdef add_ref(self, obj)

cdef class Mlx5Cqe64(PyverbsObject):
Expand Down
7 changes: 5 additions & 2 deletions pyverbs/providers/mlx5/mlx5dv.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ from pyverbs.providers.mlx5.mlx5dv_mkey cimport Mlx5MrInterleaved, Mlx5Mkey, \
Mlx5MkeyConfAttr, Mlx5SigBlockAttr
from pyverbs.providers.mlx5.mlx5dv_crypto cimport Mlx5CryptoLoginAttr, Mlx5CryptoAttr
from pyverbs.pyverbs_error import PyverbsUserError, PyverbsRDMAError, PyverbsError
from pyverbs.providers.mlx5.dr_action cimport DrActionFlowCounter
from pyverbs.providers.mlx5.dr_action cimport DrActionFlowCounter, DrActionDestTir
from pyverbs.providers.mlx5.mlx5dv_sched cimport Mlx5dvSchedLeaf
cimport pyverbs.providers.mlx5.mlx5dv_enums as dve
cimport pyverbs.providers.mlx5.libmlx5 as dv
Expand Down Expand Up @@ -177,6 +177,7 @@ cdef class Mlx5DevxObj(PyverbsCM):
self.context = context
self.context.add_ref(self)
self.flow_counter_actions = weakref.WeakSet()
self.dest_tir_actions = weakref.WeakSet()

def query(self, in_, outlen):
"""
Expand Down Expand Up @@ -227,6 +228,8 @@ cdef class Mlx5DevxObj(PyverbsCM):
cdef add_ref(self, obj):
if isinstance(obj, DrActionFlowCounter):
self.flow_counter_actions.add(obj)
elif isinstance(obj, DrActionDestTir):
self.dest_tir_actions.add(obj)
else:
raise PyverbsError('Unrecognized object type')

Expand All @@ -244,7 +247,7 @@ cdef class Mlx5DevxObj(PyverbsCM):
cpdef close(self):
if self.obj != NULL:
self.logger.debug('Closing Mlx5DvexObj')
close_weakrefs([self.flow_counter_actions])
close_weakrefs([self.flow_counter_actions, self.dest_tir_actions])
rc = dv.mlx5dv_devx_obj_destroy(self.obj)
if rc:
raise PyverbsRDMAError('Failed to destroy a DevX object', rc)
Expand Down

0 comments on commit f50a9c7

Please sign in to comment.