From: Yishai Hadas <yishaih@nvidia.com>
To: <linux-rdma@vger.kernel.org>
Cc: <jgg@nvidia.com>, <yishaih@nvidia.com>, <maorg@nvidia.com>,
<markzhang@nvidia.com>, <edwards@nvidia.com>,
Ido Kalir <idok@nvidia.com>
Subject: [PATCH rdma-core 23/27] pyverbs/mlx5: Wrap mlx5_cqe64 struct and add enums
Date: Tue, 20 Jul 2021 11:16:43 +0300 [thread overview]
Message-ID: <20210720081647.1980-24-yishaih@nvidia.com> (raw)
In-Reply-To: <20210720081647.1980-1-yishaih@nvidia.com>
From: Edward Srouji <edwards@nvidia.com>
Add a Mlx5Cqe64 class that wraps mlx5_cqe64 C struct, and provide an
easy way to users to get/set its fields.
In addition expose related enums.
Both are relevant and necessary for DevX data path.
Reviewed-by: Ido Kalir <idok@nvidia.com>
Signed-off-by: Edward Srouji <edwards@nvidia.com>
---
pyverbs/providers/mlx5/libmlx5.pxd | 14 +++++++
pyverbs/providers/mlx5/mlx5dv.pxd | 3 ++
pyverbs/providers/mlx5/mlx5dv.pyx | 71 +++++++++++++++++++++++++++++++++
pyverbs/providers/mlx5/mlx5dv_enums.pxd | 22 ++++++++++
4 files changed, 110 insertions(+)
diff --git a/pyverbs/providers/mlx5/libmlx5.pxd b/pyverbs/providers/mlx5/libmlx5.pxd
index de4008d..af034ad 100644
--- a/pyverbs/providers/mlx5/libmlx5.pxd
+++ b/pyverbs/providers/mlx5/libmlx5.pxd
@@ -273,12 +273,26 @@ cdef extern from 'infiniband/mlx5dv.h':
qp qp
srq srq
+ cdef struct mlx5_cqe64:
+ uint16_t wqe_id
+ uint32_t imm_inval_pkey
+ uint32_t byte_cnt
+ uint64_t timestamp
+ uint16_t wqe_counter
+ uint8_t signature
+ uint8_t op_own
+
void mlx5dv_set_ctrl_seg(mlx5_wqe_ctrl_seg *seg, uint16_t pi, uint8_t opcode,
uint8_t opmod, uint32_t qp_num, uint8_t fm_ce_se,
uint8_t ds, uint8_t signature, uint32_t imm)
void mlx5dv_set_data_seg(mlx5_wqe_data_seg *seg, uint32_t length,
uint32_t lkey, uintptr_t address)
+ uint8_t mlx5dv_get_cqe_owner(mlx5_cqe64 *cqe)
+ void mlx5dv_set_cqe_owner(mlx5_cqe64 *cqe, uint8_t val)
+ uint8_t mlx5dv_get_cqe_se(mlx5_cqe64 *cqe)
+ uint8_t mlx5dv_get_cqe_format(mlx5_cqe64 *cqe)
+ uint8_t mlx5dv_get_cqe_opcode(mlx5_cqe64 *cqe)
bool mlx5dv_is_supported(v.ibv_device *device)
v.ibv_context* mlx5dv_open_device(v.ibv_device *device,
mlx5dv_context_attr *attr)
diff --git a/pyverbs/providers/mlx5/mlx5dv.pxd b/pyverbs/providers/mlx5/mlx5dv.pxd
index 2b758fe..968cbdb 100644
--- a/pyverbs/providers/mlx5/mlx5dv.pxd
+++ b/pyverbs/providers/mlx5/mlx5dv.pxd
@@ -83,3 +83,6 @@ cdef class Mlx5DevxObj(PyverbsCM):
cdef dv.mlx5dv_devx_obj *obj
cdef Context context
cdef object out_view
+
+cdef class Mlx5Cqe64(PyverbsObject):
+ cdef dv.mlx5_cqe64 *cqe
diff --git a/pyverbs/providers/mlx5/mlx5dv.pyx b/pyverbs/providers/mlx5/mlx5dv.pyx
index ab0bd4a..8d6bae0 100644
--- a/pyverbs/providers/mlx5/mlx5dv.pyx
+++ b/pyverbs/providers/mlx5/mlx5dv.pyx
@@ -1507,3 +1507,74 @@ cdef class Mlx5UMEM(PyverbsCM):
def umem_addr(self):
if self.addr:
return <uintptr_t><void*>self.addr
+
+
+cdef class Mlx5Cqe64(PyverbsObject):
+ def __init__(self, addr):
+ self.cqe = <dv.mlx5_cqe64*><uintptr_t> addr
+
+ def dump(self):
+ dump_format = '{:08x} {:08x} {:08x} {:08x}\n'
+ str = ''
+ for i in range(0, 16, 4):
+ str += dump_format.format(be32toh((<uint32_t*>self.cqe)[i]),
+ be32toh((<uint32_t*>self.cqe)[i + 1]),
+ be32toh((<uint32_t*>self.cqe)[i + 2]),
+ be32toh((<uint32_t*>self.cqe)[i + 3]))
+ return str
+
+ def is_empty(self):
+ for i in range(16):
+ if be32toh((<uint32_t*>self.cqe)[i]) != 0:
+ return False
+ return True
+
+ @property
+ def owner(self):
+ return dv.mlx5dv_get_cqe_owner(self.cqe)
+ @owner.setter
+ def owner(self, val):
+ dv.mlx5dv_set_cqe_owner(self.cqe, <uint8_t> val)
+
+ @property
+ def se(self):
+ return dv.mlx5dv_get_cqe_se(self.cqe)
+
+ @property
+ def format(self):
+ return dv.mlx5dv_get_cqe_format(self.cqe)
+
+ @property
+ def opcode(self):
+ return dv.mlx5dv_get_cqe_opcode(self.cqe)
+
+ @property
+ def imm_inval_pkey(self):
+ return be32toh(self.cqe.imm_inval_pkey)
+
+ @property
+ def wqe_id(self):
+ return be16toh(self.cqe.wqe_id)
+
+ @property
+ def byte_cnt(self):
+ return be32toh(self.cqe.byte_cnt)
+
+ @property
+ def timestamp(self):
+ return be64toh(self.cqe.timestamp)
+
+ @property
+ def wqe_counter(self):
+ return be16toh(self.cqe.wqe_counter)
+
+ @property
+ def signature(self):
+ return self.cqe.signature
+
+ @property
+ def op_own(self):
+ return self.cqe.op_own
+
+ def __str__(self):
+ return (<dv.mlx5_cqe64>((<dv.mlx5_cqe64*>self.cqe)[0])).__str__()
diff --git a/pyverbs/providers/mlx5/mlx5dv_enums.pxd b/pyverbs/providers/mlx5/mlx5dv_enums.pxd
index 9f8d1a1..60713e8 100644
--- a/pyverbs/providers/mlx5/mlx5dv_enums.pxd
+++ b/pyverbs/providers/mlx5/mlx5dv_enums.pxd
@@ -193,6 +193,28 @@ cdef extern from 'infiniband/mlx5dv.h':
MLX5DV_OBJ_AH
MLX5DV_OBJ_PD
+ cpdef enum:
+ MLX5_RCV_DBR
+ MLX5_SND_DBR
+
+ cpdef enum:
+ MLX5_CQE_OWNER_MASK
+ MLX5_CQE_REQ
+ MLX5_CQE_RESP_WR_IMM
+ MLX5_CQE_RESP_SEND
+ MLX5_CQE_RESP_SEND_IMM
+ MLX5_CQE_RESP_SEND_INV
+ MLX5_CQE_RESIZE_CQ
+ MLX5_CQE_NO_PACKET
+ MLX5_CQE_SIG_ERR
+ MLX5_CQE_REQ_ERR
+ MLX5_CQE_RESP_ERR
+ MLX5_CQE_INVALID
+
+ cpdef enum:
+ MLX5_SEND_WQE_BB
+ MLX5_SEND_WQE_SHIFT
+
cpdef unsigned long long MLX5DV_RES_TYPE_QP
cpdef unsigned long long MLX5DV_RES_TYPE_RWQ
cpdef unsigned long long MLX5DV_RES_TYPE_DBR
--
1.8.3.1
next prev parent reply other threads:[~2021-07-20 8:19 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-20 8:16 [PATCH rdma-core 00/27] Introduce mlx5 user space driver over VFIO Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 01/27] Update kernel headers Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 02/27] mlx5: Introduce mlx5dv_get_vfio_device_list() Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 03/27] mlx5: Enable debug functionality for vfio Yishai Hadas
2021-07-20 8:51 ` Leon Romanovsky
2021-07-20 9:27 ` Yishai Hadas
2021-07-20 12:27 ` Leon Romanovsky
2021-07-20 14:57 ` Yishai Hadas
2021-07-21 7:05 ` Gal Pressman
2021-07-21 7:58 ` Yishai Hadas
2021-07-21 8:51 ` Gal Pressman
2021-07-20 8:16 ` [PATCH rdma-core 04/27] util: Add interval_set support Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 05/27] verbs: Enable verbs_open_device() to work over non sysfs devices Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 06/27] mlx5: Setup mlx5 vfio context Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 07/27] mlx5: Add mlx5_vfio_cmd_exec() support Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 08/27] mlx5: vfio setup function support Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 09/27] mlx5: vfio setup basic caps Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 10/27] mlx5: Support fast teardown over vfio Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 11/27] mlx5: Enable interrupt command mode " Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 12/27] mlx5: Introduce vfio APIs to process events Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 13/27] mlx5: VFIO poll_health support Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 14/27] mlx5: Implement basic verbs operation for PD and MR over vfio Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 15/27] mlx5: Set DV context ops Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 16/27] mlx5: Support initial DEVX/DV APIs over vfio Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 17/27] mlx5: Implement mlx5dv devx_obj " Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 18/27] pyverbs: Support DevX UMEM registration Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 19/27] pyverbs/mlx5: Support EQN querying Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 20/27] pyverbs/mlx5: Support more DevX objects Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 21/27] pyverbs: Add auxiliary memory functions Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 22/27] pyverbs/mlx5: Add support to extract mlx5dv objects Yishai Hadas
2021-07-20 8:16 ` Yishai Hadas [this message]
2021-07-20 8:16 ` [PATCH rdma-core 24/27] tests: Add MAC address to the tests' args Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 25/27] tests: Add mlx5 DevX data path test Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 26/27] pyverbs/mlx5: Support mlx5 devices over VFIO Yishai Hadas
2021-07-20 8:16 ` [PATCH rdma-core 27/27] tests: Add a test for mlx5 " Yishai Hadas
2021-08-01 8:00 ` [PATCH rdma-core 00/27] Introduce mlx5 user space driver " Yishai Hadas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210720081647.1980-24-yishaih@nvidia.com \
--to=yishaih@nvidia.com \
--cc=edwards@nvidia.com \
--cc=idok@nvidia.com \
--cc=jgg@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
--cc=maorg@nvidia.com \
--cc=markzhang@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).