From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 46C0AA034F; Fri, 8 Oct 2021 12:56:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C2FE41167; Fri, 8 Oct 2021 12:56:09 +0200 (CEST) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by mails.dpdk.org (Postfix) with ESMTP id 9CCB4411E0 for ; Thu, 7 Oct 2021 20:44:43 +0200 (CEST) Received: by mail-pf1-f173.google.com with SMTP id s16so6135282pfk.0 for ; Thu, 07 Oct 2021 11:44:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mbh1s+rh+MkUb9pvFqVwTsGJ/VKmy3Eq9nDowNYtNPg=; b=WG3WoAmxMxdNP5cvI5clJJzmY2FdHZnZxLntToenE8ySmtNmCzzSDpJG/MxpJHdPA1 s3YHOAvMkgIBKKiHz/qs4tOS0T+1wmqmpTSTjbUjtbx3I+hx4ZV5F/SR9LQGQJztUhzR eELEGrhYHaTQ+7HWBDz8cqJRDexwIPg3BeOuw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mbh1s+rh+MkUb9pvFqVwTsGJ/VKmy3Eq9nDowNYtNPg=; b=25uFBv+y6P4kLvtBCjPQqaI+gGj2pfv3394t9dl2fNI2g3n19aibwX/eALliW8kZSY F7a49CtCard55dGBkHj8HLpHSLAikuBqQP/rNeoKiX5VloJDQtWQnKcCYyJyb72MLV07 TSK8yL9u1lqyLcUMGWy7nTgbb4NjIyjW6p9aS5uaWzCJAOmQqXtD6KcqpBZ/iqC1boNH ywbv7dXF2FXTPQ+YXDeE0MQcey12kfJbXk4dkQ8THhcD6fT1bNg+2gHjb01hMopYwm6Y Et0ozJ1VnkkwmbbbQH53Q2HT0uWCMuw1HE+wPvvoi6mFFGQ8p1/gsCwTplnuY8+8tsfk LRYw== X-Gm-Message-State: AOAM532jFI2+KeNGfVZJ5E/cb6w0hSiPVwNfzxlq5xHSL5AVmjB1Xvh/ XMWpiu79D14fKeqEnHcErICUjw== X-Google-Smtp-Source: ABdhPJxFeSAzVcHyZeMblLBZ+B83UYJpLaSpsPna2GHwq4G5f24gha8pgBsXfTSTnR2ANWyPOiKFEg== X-Received: by 2002:a63:5b09:: with SMTP id p9mr966357pgb.321.1633632282835; Thu, 07 Oct 2021 11:44:42 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([136.185.113.102]) by smtp.gmail.com with ESMTPSA id c11sm3311586pji.38.2021.10.07.11.44.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 11:44:42 -0700 (PDT) From: Srikanth Kaka To: Matan Azrad , Viacheslav Ovsiienko Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Fri, 8 Oct 2021 00:13:20 +0530 Message-Id: <20211007184350.73858-12-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211007184350.73858-1-srikanth.k@oneconvergence.com> References: <20211007184350.73858-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 08 Oct 2021 12:55:54 +0200 Subject: [dpdk-dev] [PATCH v2 11/41] common/mlx5: add mr reg/dereg API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The mlx5_common_verbs_reg_mr() and mlx5_common_verbs_dereg_mr() APIs are equivalent to their Linux counterparts Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/common/mlx5/freebsd/meson.build | 1 + .../common/mlx5/freebsd/mlx5_common_verbs.c | 73 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 drivers/common/mlx5/freebsd/mlx5_common_verbs.c diff --git a/drivers/common/mlx5/freebsd/meson.build b/drivers/common/mlx5/freebsd/meson.build index 8e4bb1659e..4112fdb155 100644 --- a/drivers/common/mlx5/freebsd/meson.build +++ b/drivers/common/mlx5/freebsd/meson.build @@ -33,6 +33,7 @@ endif sources += files('mlx5_common_os.c') sources += files('mlx5_glue.c') +sources += files('mlx5_common_verbs.c') # To maintain the compatibility with the make build system # mlx5_autoconf.h file is still generated. diff --git a/drivers/common/mlx5/freebsd/mlx5_common_verbs.c b/drivers/common/mlx5/freebsd/mlx5_common_verbs.c new file mode 100644 index 0000000000..efb039c53d --- /dev/null +++ b/drivers/common/mlx5/freebsd/mlx5_common_verbs.c @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "mlx5_common_utils.h" +#include "mlx5_common_log.h" +#include "mlx5_common_private.h" +#include "mlx5_autoconf.h" +#include +#include +#include + +/** + * Register mr. Given protection domain pointer, pointer to addr and length + * register the memory region. + * + * @param[in] pd + * Pointer to protection domain context. + * @param[in] addr + * Pointer to memory start address. + * @param[in] length + * Length of the memory to register. + * @param[out] pmd_mr + * pmd_mr struct set with lkey, address, length and pointer to mr object + * + * @return + * 0 on successful registration, -1 otherwise + */ +int +mlx5_common_verbs_reg_mr(void *pd, void *addr, size_t length, + struct mlx5_pmd_mr *pmd_mr) +{ + struct ibv_mr *ibv_mr; + + ibv_mr = mlx5_glue->reg_mr(pd, addr, length, + IBV_ACCESS_LOCAL_WRITE | + (haswell_broadwell_cpu ? 0 : + IBV_ACCESS_RELAXED_ORDERING)); + if (!ibv_mr) + return -1; + + *pmd_mr = (struct mlx5_pmd_mr){ + .lkey = ibv_mr->lkey, + .addr = ibv_mr->addr, + .len = ibv_mr->length, + .obj = (void *)ibv_mr, + }; + return 0; +} + +/** + * Deregister mr. Given the mlx5 pmd MR - deregister the MR + * + * @param[in] pmd_mr + * pmd_mr struct set with lkey, address, length and pointer to mr object + * + */ +void +mlx5_common_verbs_dereg_mr(struct mlx5_pmd_mr *pmd_mr) +{ + if (pmd_mr && pmd_mr->obj != NULL) { + claim_zero(mlx5_glue->dereg_mr(pmd_mr->obj)); + memset(pmd_mr, 0, sizeof(*pmd_mr)); + } +} -- 2.30.2