From patchwork Sun Feb 24 13:06:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noa Osherovich X-Patchwork-Id: 10827933 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 73F3E188D for ; Sun, 24 Feb 2019 13:08:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62A062B4AD for ; Sun, 24 Feb 2019 13:08:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 574002B525; Sun, 24 Feb 2019 13:08:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F13452B4AD for ; Sun, 24 Feb 2019 13:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728204AbfBXNIu (ORCPT ); Sun, 24 Feb 2019 08:08:50 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:50424 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726835AbfBXNIu (ORCPT ); Sun, 24 Feb 2019 08:08:50 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from noaos@mellanox.com) with ESMTPS (AES256-SHA encrypted); 24 Feb 2019 15:06:48 +0200 Received: from reg-l-vrt-059-009.mtl.labs.mlnx (reg-l-vrt-059-009.mtl.labs.mlnx [10.135.59.9]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x1OD6mfX026210; Sun, 24 Feb 2019 15:06:48 +0200 From: Noa Osherovich To: leonro@mellanox.com, jgg@mellanox.com, dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Noa Osherovich Subject: [PATCH rdma-core 03/19] pyverbs: Use new-style properties Date: Sun, 24 Feb 2019 15:06:22 +0200 Message-Id: <20190224130638.31848-4-noaos@mellanox.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190224130638.31848-1-noaos@mellanox.com> References: <20190224130638.31848-1-noaos@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When declaring properties, declare them the same way as ordinary Python code instead of using deprecated legacy syntax. Signed-off-by: Noa Osherovich --- pyverbs/addr.pyx | 55 +++++------ pyverbs/device.pyx | 234 ++++++++++++++++++++++----------------------- 2 files changed, 145 insertions(+), 144 deletions(-) diff --git a/pyverbs/addr.pyx b/pyverbs/addr.pyx index 0f171e83ea21..5713f9392d0f 100644 --- a/pyverbs/addr.pyx +++ b/pyverbs/addr.pyx @@ -13,34 +13,35 @@ cdef class GID(PyverbsObject): """ GID class represents ibv_gid. It enables user to query for GIDs values. """ - property gid: - def __get__(self): - """ - Expose the inner GID - :return: A GID string in an 8 words format: - 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx' - """ - return self.__str__() - def __set__(self, val): - """ - Sets the inner GID - :param val: A GID string in an 8 words format: - 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx' - :return: None - """ - val = val.split(':') - if len(val) != 8: - raise PyverbsUserError("Invalid GID value ({val})".format(val=val)) - if any([len(v) != 4 for v in val]): - raise PyverbsUserError("Invalid GID value ({val})".format(val=val)) - val_int = int("".join(val), 16) - vals = [] - for i in range(8): - vals.append(val[i][0:2]) - vals.append(val[i][2:4]) + @property + def gid(self): + """ + Expose the inner GID + :return: A GID string in an 8 words format: + 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx' + """ + return self.__str__() + @gid.setter + def gid(self, val): + """ + Sets the inner GID + :param val: A GID string in an 8 words format: + 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx' + :return: None + """ + val = val.split(':') + if len(val) != 8: + raise PyverbsUserError("Invalid GID value ({val})".format(val=val)) + if any([len(v) != 4 for v in val]): + raise PyverbsUserError("Invalid GID value ({val})".format(val=val)) + val_int = int("".join(val), 16) + vals = [] + for i in range(8): + vals.append(val[i][0:2]) + vals.append(val[i][2:4]) - for i in range(16): - self.gid.raw[i] = int(vals[i],16) + for i in range(16): + self.gid.raw[i] = int(vals[i],16) def __str__(self): hex_values = '%016x%016x' % (be64toh(self.gid._global.subnet_prefix), diff --git a/pyverbs/device.pyx b/pyverbs/device.pyx index cb3baed38afa..0264a4f0bddd 100644 --- a/pyverbs/device.pyx +++ b/pyverbs/device.pyx @@ -141,123 +141,123 @@ cdef class DeviceAttr(PyverbsObject): properties (read only) and also provides an __str__() function for readability. """ - property fw_version: - def __get__(self): - return self.dev_attr.fw_ver.decode() - property node_guid: - def __get__(self): - return self.dev_attr.node_guid - property sys_image_guid: - def __get__(self): - return self.dev_attr.sys_image_guid - property max_mr_size: - def __get__(self): - return self.dev_attr.max_mr_size - property page_size_cap: - def __get__(self): - return self.dev_attr.page_size_cap - property vendor_id: - def __get__(self): - return self.dev_attr.vendor_id - property vendor_part_id: - def __get__(self): - return self.dev_attr.vendor_part_id - property hw_ver: - def __get__(self): - return self.dev_attr.hw_ver - property max_qp: - def __get__(self): - return self.dev_attr.max_qp - property max_qp_wr: - def __get__(self): - return self.dev_attr.max_qp_wr - property device_cap_flags: - def __get__(self): - return self.dev_attr.device_cap_flags - property max_sge: - def __get__(self): - return self.dev_attr.max_sge - property max_sge_rd: - def __get__(self): - return self.dev_attr.max_sge_rd - property max_cq: - def __get__(self): - return self.dev_attr.max_cq - property max_cqe: - def __get__(self): - return self.dev_attr.max_cqe - property max_mr: - def __get__(self): - return self.dev_attr.max_mr - property max_pd: - def __get__(self): - return self.dev_attr.max_pd - property max_qp_rd_atom: - def __get__(self): - return self.dev_attr.max_qp_rd_atom - property max_ee_rd_atom: - def __get__(self): - return self.dev_attr.max_ee_rd_atom - property max_res_rd_atom: - def __get__(self): - return self.dev_attr.max_res_rd_atom - property max_qp_init_rd_atom: - def __get__(self): - return self.dev_attr.max_qp_init_rd_atom - property max_ee_init_rd_atom: - def __get__(self): - return self.dev_attr.max_ee_init_rd_atom - property atomic_caps: - def __get__(self): - return self.dev_attr.atomic_cap - property max_ee: - def __get__(self): - return self.dev_attr.max_ee - property max_rdd: - def __get__(self): - return self.dev_attr.max_rdd - property max_mw: - def __get__(self): - return self.dev_attr.max_mw - property max_raw_ipv6_qps: - def __get__(self): - return self.dev_attr.max_raw_ipv6_qp - property max_raw_ethy_qp: - def __get__(self): - return self.dev_attr.max_raw_ethy_qp - property max_mcast_grp: - def __get__(self): - return self.dev_attr.max_mcast_grp - property max_mcast_qp_attach: - def __get__(self): - return self.dev_attr.max_mcast_qp_attach - property max_ah: - def __get__(self): - return self.dev_attr.max_ah - property max_fmr: - def __get__(self): - return self.dev_attr.max_fmr - property max_map_per_fmr: - def __get__(self): - return self.dev_attr.max_map_per_fmr - property max_srq: - def __get__(self): - return self.dev_attr.max_srq - property max_srq_wr: - def __get__(self): - return self.dev_attr.max_srq_wr - property max_srq_sge: - def __get__(self): - return self.dev_attr.max_srq_sge - property max_pkeys: - def __get__(self): - return self.dev_attr.max_pkeys - property local_ca_ack_delay: - def __get__(self): - return self.dev_attr.local_ca_ack_delay - property phys_port_cnt: - def __get__(self): - return self.dev_attr.phys_port_cnt + @property + def fw_version(self): + return self.dev_attr.fw_ver.decode() + @property + def node_guid(self): + return self.dev_attr.node_guid + @property + def sys_image_guid(self): + return self.dev_attr.sys_image_guid + @property + def max_mr_size(self): + return self.dev_attr.max_mr_size + @property + def page_size_cap(self): + return self.dev_attr.page_size_cap + @property + def vendor_id(self): + return self.dev_attr.vendor_id + @property + def vendor_part_id(self): + return self.dev_attr.vendor_part_id + @property + def hw_ver(self): + return self.dev_attr.hw_ver + @property + def max_qp(self): + return self.dev_attr.max_qp + @property + def max_qp_wr(self): + return self.dev_attr.max_qp_wr + @property + def device_cap_flags(self): + return self.dev_attr.device_cap_flags + @property + def max_sge(self): + return self.dev_attr.max_sge + @property + def max_sge_rd(self): + return self.dev_attr.max_sge_rd + @property + def max_cq(self): + return self.dev_attr.max_cq + @property + def max_cqe(self): + return self.dev_attr.max_cqe + @property + def max_mr(self): + return self.dev_attr.max_mr + @property + def max_pd(self): + return self.dev_attr.max_pd + @property + def max_qp_rd_atom(self): + return self.dev_attr.max_qp_rd_atom + @property + def max_ee_rd_atom(self): + return self.dev_attr.max_ee_rd_atom + @property + def max_res_rd_atom(self): + return self.dev_attr.max_res_rd_atom + @property + def max_qp_init_rd_atom(self): + return self.dev_attr.max_qp_init_rd_atom + @property + def max_ee_init_rd_atom(self): + return self.dev_attr.max_ee_init_rd_atom + @property + def atomic_caps(self): + return self.dev_attr.atomic_cap + @property + def max_ee(self): + return self.dev_attr.max_ee + @property + def max_rdd(self): + return self.dev_attr.max_rdd + @property + def max_mw(self): + return self.dev_attr.max_mw + @property + def max_raw_ipv6_qps(self): + return self.dev_attr.max_raw_ipv6_qp + @property + def max_raw_ethy_qp(self): + return self.dev_attr.max_raw_ethy_qp + @property + def max_mcast_grp(self): + return self.dev_attr.max_mcast_grp + @property + def max_mcast_qp_attach(self): + return self.dev_attr.max_mcast_qp_attach + @property + def max_ah(self): + return self.dev_attr.max_ah + @property + def max_fmr(self): + return self.dev_attr.max_fmr + @property + def max_map_per_fmr(self): + return self.dev_attr.max_map_per_fmr + @property + def max_srq(self): + return self.dev_attr.max_srq + @property + def max_srq_wr(self): + return self.dev_attr.max_srq_wr + @property + def max_srq_sge(self): + return self.dev_attr.max_srq_sge + @property + def max_pkeys(self): + return self.dev_attr.max_pkeys + @property + def local_ca_ack_delay(self): + return self.dev_attr.local_ca_ack_delay + @property + def phys_port_cnt(self): + return self.dev_attr.phys_port_cnt def __str__(self): print_format = '{:<22}: {:<20}\n'