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 9D12DA0C4D; Mon, 8 Nov 2021 11:47:55 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5E3DD41151; Mon, 8 Nov 2021 11:47:13 +0100 (CET) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2068.outbound.protection.outlook.com [40.107.223.68]) by mails.dpdk.org (Postfix) with ESMTP id 06B2F4113D for ; Mon, 8 Nov 2021 11:47:10 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TBds01TGv+goJyD1dB72+mYk6wZYifc/UXQcrI40e5qdhOcQYQi7O3JP/nIptMql5nAyarPaGfJMzPiqlsuP6ohFao2j3qm5j9q2EWv2S81kII1w36NztYKZC5bRlJQ4xFT+jikme7LQ3M4UvjTS0Rw7+RX1d/rF2YIDJu6kysIK9zvLgJdjjSroaZ8jbHwwi3DQ71p/qC9AGrorUfroEv1LVs+TIC/NelkHdf/HGaKIt4u05K9pDjErYL75WfEgtP8p1eB/PIydktxqiUy9cglOKVzGt2hMJoZA4clN0A8TmlhsVMp+Bzn6po3540wTcFDqP9DFgv+yoOrzbOWo4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zIGv8TrgVKAELEpyoxP8Y1BNCXyegMlzXpEHofm9OVI=; b=bLRo7zY+3O8beMs/xPFbhwuyWcG9k27MmxS/kIygCMZ+Bsl0f8OJDc1UHbOBqky4JbbwdC5M17fuFeMew2nXGTQx9AsDZxcLP5btPw5Vm1ZAr+Di02lp0Gf5tHySifZWIBwvZ5UqMZ9/hD1o4WLYai8cUfLzxlg6tqdu2N4QioB20EQ3u8DIkgcvU0qjjx1wfkEvb2wwaDSlKgsOay76eQzLGYoeXtcdwc0Py3l3PSvfXORbU1gmpL8aD9prOCbe/7BFzdVqzyVPdtTP3aX0NgqXMdjyl93VwPqswCMtLROzfywFjBpPrOf7sfQ94KyeWAuefVC5rW4a/nxpYEwBlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zIGv8TrgVKAELEpyoxP8Y1BNCXyegMlzXpEHofm9OVI=; b=BKHoruBlwfREFbAwL0YBmM4TbPHYQsH5oQoH5dTIqZs+D096SCx5lIrfpHwOeTgkuMHyDEHea+lKIhgdMzS8Ukffaj6MKL1J994WNaEn6DlbVvzLYNTLs+ocCRUqW1LXHuOx/OBRLKFjkI2sArgCsMl03JqFFio0AJsmu5JHn7c3bnWRinLW4bQqnao/yEGhzc9zCu0D4HPaWHf3maXK/izxf29wvCDJ5fqGNReuJ3d2GkZefH1+imqTY6ZxoyYvEw1eZdrDA5WE1Zaejvk/0fArkeuM/3fA39lBVxA/UqfMbB4pVjC65gDeLQj1n4tzVVP5BoWNslIY3zSQN61MjQ== Received: from MW2PR16CA0053.namprd16.prod.outlook.com (2603:10b6:907:1::30) by BY5PR12MB4242.namprd12.prod.outlook.com (2603:10b6:a03:203::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Mon, 8 Nov 2021 10:47:08 +0000 Received: from CO1NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:907:1:cafe::fd) by MW2PR16CA0053.outlook.office365.com (2603:10b6:907:1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Mon, 8 Nov 2021 10:47:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT064.mail.protection.outlook.com (10.13.175.77) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4669.10 via Frontend Transport; Mon, 8 Nov 2021 10:47:07 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 8 Nov 2021 10:47:01 +0000 From: To: CC: Elena Agostini Date: Mon, 8 Nov 2021 18:58:02 +0000 Message-ID: <20211108185805.3887-7-eagostini@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211108185805.3887-1-eagostini@nvidia.com> References: <20210602203531.2288645-1-thomas@monjalon.net> <20211108185805.3887-1-eagostini@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f1915d67-6a53-4350-0648-08d9a2a51c78 X-MS-TrafficTypeDiagnostic: BY5PR12MB4242: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0dL8hcvA6o+VufsoZ5yZ8Kb3MGm+YtwqIqXwIOYSJk7xtvdlQHtlgT/cGnuadvU5s57gOW4i/If13GW5PJ2VRPVf8al/eaOI35Zzg6p4gD1qHpXVJT26/ZUk+TvStaBvtC7Tmgj8d32xyqKKynnh971hCmyLDEP5aFe5vfyQhvGDIohBRCUJaHy0fZ6PEL3gTlj8VjwcTxv/ZKH+YAcYLl+wzfFB7oblacPkMgzuyq8J6wL4juwYbyuWShgQbIslPpyDdtICiuwERTehEg+UDVR4Z30PUeUhPBjGwFDqLgLNrEiLXKpNyg1kzBFeo3EtOYUFDwV02O2UNBS8Hj7TyDePyiiFkfXvDqiXMdpgj9J4DeVrds1HYGW/WXnwa/SDxp9ckatZalClpiIp4YAbYQCqt5uUc9jU0Sd0a/vMcL0pL7TRgANMbTY2N4wZF12Juup794T7BXA1vYv+4/wHndFjbNhow3KxBv44a/vH0PPa3QvnlMQk79ZNgbD3RDFZZpLuTejUkqgqPk6QzPOKJIkarF5I0bhSxQb+Wr7C0sVeq+KlAxM0tx1eNVAnmuqH3H3k0ggm9ypSi9eklJ0NcQEj3Pdhysoi3ORl8tD95F8NhS8D0r88DRC7jw3Ahh++SvkpNfG9OaA5QjQhROuZ4CHYfQ+moU6QiDvo2m3QZ7am/ASxIjHl3WJOCmiUYx6XbVWJxgEqiHh/J7KlHymzxg== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(36840700001)(46966006)(6286002)(5660300002)(86362001)(2906002)(26005)(2876002)(7636003)(186003)(16526019)(7696005)(1076003)(36756003)(36860700001)(508600001)(55016002)(83380400001)(82310400003)(8936002)(4326008)(426003)(47076005)(336012)(6916009)(8676002)(70206006)(316002)(107886003)(356005)(70586007)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Nov 2021 10:47:07.9467 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1915d67-6a53-4350-0648-08d9a2a51c78 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4242 Subject: [dpdk-dev] [PATCH v5 6/9] gpudev: add memory barrier 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" From: Elena Agostini Add a function for the application to ensure the coherency of the writes executed by another device into the GPU memory. Signed-off-by: Elena Agostini --- doc/guides/prog_guide/gpudev.rst | 8 ++++++++ lib/gpudev/gpudev.c | 19 +++++++++++++++++++ lib/gpudev/gpudev_driver.h | 3 +++ lib/gpudev/rte_gpudev.h | 18 ++++++++++++++++++ lib/gpudev/version.map | 1 + 5 files changed, 49 insertions(+) diff --git a/doc/guides/prog_guide/gpudev.rst b/doc/guides/prog_guide/gpudev.rst index 9aca69038c..eb5f0af817 100644 --- a/doc/guides/prog_guide/gpudev.rst +++ b/doc/guides/prog_guide/gpudev.rst @@ -65,3 +65,11 @@ gpudev can register a CPU memory area to make it visible from a GPU device. Later, it's also possible to unregister that memory with gpudev. CPU memory registered outside of the gpudev library (e.g. with GPU specific library) cannot be unregistered by the gpudev library. + +Memory Barrier +~~~~~~~~~~~~~~ + +Some GPU drivers may need, under certain conditions, +to enforce the coherency of external devices writes (e.g. NIC receiving packets) +into the GPU memory. +gpudev abstracts and exposes this capability. diff --git a/lib/gpudev/gpudev.c b/lib/gpudev/gpudev.c index d0826ec881..49526b335f 100644 --- a/lib/gpudev/gpudev.c +++ b/lib/gpudev/gpudev.c @@ -624,3 +624,22 @@ rte_gpu_free(int16_t dev_id, void *ptr) } return GPU_DRV_RET(dev->ops.mem_free(dev, ptr)); } + +int +rte_gpu_mbw(int16_t dev_id) +{ + struct rte_gpu *dev; + + dev = gpu_get_by_id(dev_id); + if (dev == NULL) { + GPU_LOG(ERR, "memory barrier for invalid device ID %d", dev_id); + rte_errno = ENODEV; + return -rte_errno; + } + + if (dev->ops.mbw == NULL) { + rte_errno = ENOTSUP; + return -rte_errno; + } + return GPU_DRV_RET(dev->ops.mbw(dev)); +} diff --git a/lib/gpudev/gpudev_driver.h b/lib/gpudev/gpudev_driver.h index 11015944a6..ab24de9e28 100644 --- a/lib/gpudev/gpudev_driver.h +++ b/lib/gpudev/gpudev_driver.h @@ -31,6 +31,7 @@ typedef int (rte_gpu_mem_alloc_t)(struct rte_gpu *dev, size_t size, void **ptr); typedef int (rte_gpu_free_t)(struct rte_gpu *dev, void *ptr); typedef int (rte_gpu_mem_register_t)(struct rte_gpu *dev, size_t size, void *ptr); typedef int (rte_gpu_mem_unregister_t)(struct rte_gpu *dev, void *ptr); +typedef int (rte_gpu_mbw_t)(struct rte_gpu *dev); struct rte_gpu_ops { /* Get device info. If NULL, info is just copied. */ @@ -45,6 +46,8 @@ struct rte_gpu_ops { rte_gpu_free_t *mem_free; /* Unregister CPU memory in device. */ rte_gpu_mem_unregister_t *mem_unregister; + /* Enforce GPU memory write barrier. */ + rte_gpu_mbw_t *mbw; }; struct rte_gpu_mpshared { diff --git a/lib/gpudev/rte_gpudev.h b/lib/gpudev/rte_gpudev.h index fee71d60e7..650ebfd700 100644 --- a/lib/gpudev/rte_gpudev.h +++ b/lib/gpudev/rte_gpudev.h @@ -387,6 +387,24 @@ int rte_gpu_register(int16_t dev_id, size_t size, void *ptr); __rte_experimental int rte_gpu_unregister(int16_t dev_id, void *ptr); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Enforce a GPU memory write barrier. + * + * @param dev_id + * Reference device ID. + * + * @return + * 0 on success, -rte_errno otherwise: + * - ENODEV if invalid dev_id + * - ENOTSUP if operation not supported by the driver + * - EPERM if driver error + */ +__rte_experimental +int rte_gpu_mbw(int16_t dev_id); + #ifdef __cplusplus } #endif diff --git a/lib/gpudev/version.map b/lib/gpudev/version.map index d4a65ebd52..d72d470d8e 100644 --- a/lib/gpudev/version.map +++ b/lib/gpudev/version.map @@ -13,6 +13,7 @@ EXPERIMENTAL { rte_gpu_init; rte_gpu_is_valid; rte_gpu_malloc; + rte_gpu_mbw; rte_gpu_register; rte_gpu_unregister; }; -- 2.17.1