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 5EE11A0A02; Tue, 4 May 2021 19:57:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 86DB940697; Tue, 4 May 2021 19:57:25 +0200 (CEST) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2074.outbound.protection.outlook.com [40.107.243.74]) by mails.dpdk.org (Postfix) with ESMTP id 0AF414014E for ; Tue, 4 May 2021 19:57:25 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oe/aqSYB1wV3iPTSRZcjMkZrIRGS0pl6uoQWxZqx7IR14JsHhzYk+HAv3947Sp5IBwXRgpKtMc4987sTBRRNliCuqh3EYxCtGQjzrlvHDW0RkOCViVGOai5xPAD55bgc1yqemaNAEa6UGAXlRiUUqkHe1ZThyU+fJKumRbfXoOgfeTfl6jBi1oz3Mft0tBpgN9H5PuJZpRXt3QQR4f1p8QZ0ckQEZZndlIQVibbRRHvX3mNtxzp4Spj1sGu/ZBx3tKRxtsfBbUG1dzpRWuTncfVQQw46s5l8LHgQxNofBBMnYrSjyM5y667vMGm9b0MR7nT+up5rCt/E6GT5zQavPQ== 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-SenderADCheck; bh=e09v/aLk9NQKN4GBKVF/GxI7q4CpuWJ33sYrLCdYxUI=; b=eIv0wAHLdZMyGrCbyLxRa/kgb21XNLKZ7/O4G/XzobVi9cElFozV5ki484szw3ZLUo12YyMD6QXh7Uh00qZUJDQZwFpEGbTrTKaIp5KXr1sJqPlDQt57Krd0KfMYlMr5lde6tTW6JD29YQztQDJUpoGOz3bpDhHe9m9wd/EvLBTtn1llQa0MeyX+Ia+IhDxVl84/zAuXj0bq4bqnMJxIr0OlNqd8n3SQRWU+NI3OM5bQeQYHZqtC9I+qHKI4GkqqrdpD+ofr8q0w9XvFn92qsZmWPqU/pDq6eMhVcrkJ3jt6FkpUyy5qvJ9u51/cMYHhoTkw+H8LbFut7CM94WxPRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none 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=e09v/aLk9NQKN4GBKVF/GxI7q4CpuWJ33sYrLCdYxUI=; b=SQYa2edkcGsOSj+k9G51pbJCpAprp8OkrCmVQjp8OfZzEQSXtHQTqhpiNM0N2m4GtVBRrg0tFOjOPQADtvRdTjj92456u/YZVN93okws92euf8pc6kaxR3xPlPSt9dQF61mq+6NCB32Qm7so5xl+k0s9TziIFZOqLYUPHLYCGIJ1yv4kjCiPV4R8O+vdIHscxbKvqkYONprLjKoNBZZmraOzmOum6t1x9OtH4Tqnfnh/0COP1IGhmfB62vZBibsG3ZnoTVw3GEU+aDUV+iBobb2JH7zFG0cApAGq1sfQFahGzJcO9Lre2WbSfNSTyoq9VYDC9YUtab2+EDcbPXiZYA== Received: from DM5PR15CA0070.namprd15.prod.outlook.com (2603:10b6:3:ae::32) by CH2PR12MB4231.namprd12.prod.outlook.com (2603:10b6:610:7d::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.39; Tue, 4 May 2021 17:57:23 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:3:ae:cafe::aa) by DM5PR15CA0070.outlook.office365.com (2603:10b6:3:ae::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Tue, 4 May 2021 17:57:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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 DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4087.27 via Frontend Transport; Tue, 4 May 2021 17:57:23 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 4 May 2021 17:57:21 +0000 From: Matan Azrad To: CC: , , , "Thomas Monjalon" , Dekel Peled Date: Tue, 4 May 2021 20:54:59 +0300 Message-ID: <20210504175500.3385811-15-matan@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210504175500.3385811-1-matan@nvidia.com> References: <20210429154335.2820028-1-matan@nvidia.com> <20210504175500.3385811-1-matan@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e87e45bf-158a-4653-8c4d-08d90f261228 X-MS-TrafficTypeDiagnostic: CH2PR12MB4231: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4125; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VoSLM1ugWY0yk3hPpJ9XYoUS9s8fOcVjUCPeDiWVmO7RDCFs8+VX2aaSEi8eszXh9ijzO0lJ9rql6pZdgrADJKiB+fXucUhEG1fSXiZ62KH8Y9MrrwlNC0PB4XU1sHpWAaKFpnKhoB5O/T04tLBjvESMg+AWmth+xFpZmros6VCEnBenGq62uIuTiRgVUs646w6rX6UqK8LY52qVgybSBi0CMuV45NhqO0LHfTtP0tGP7Wrb5CjOsrSgvusFMhBYPS5Qv9ojw8McWzOXuiprqXtiS7fBQ6Kt7QThzx2uqhaLjkfHHAqsouyscscJg61k7/Z9EFbkzrKCaQl2dRDjcOPJstFk3HnaItt2sIw53Gqd+d1O3EB7OYWEC9TJWAJUzr3psc0y/lSC9eLleyHW3OoPck+HhyEN+Smve7sdkAGm242qh7GbRwfvTyNp9UKOIUFXm3V27nItwEimEaB7S1Ww0nqIwLL7cWG/fVyj9RSWF+ySfnK7h0Plxo9qAkB1hNaVP9iujstgR8oXsfJgGZ6DBdcznuymv8xc/3J9WQej9AuTiTvzLYL2R9QgAfyR2YwVEFDqAxxq4ze6jqREWm4O53N7a5GDOzPbqNr/mDzCmA/sM2Vma+X/IhDAPaOe4RYEpobw9ToBdXZnF920KrJFsY/nwLk0lYSpk9P4fus= 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)(396003)(136003)(39860400002)(376002)(346002)(36840700001)(46966006)(8676002)(2616005)(8936002)(82310400003)(186003)(6916009)(2906002)(7636003)(82740400003)(4326008)(83380400001)(356005)(107886003)(54906003)(1076003)(70206006)(36756003)(70586007)(426003)(336012)(7696005)(5660300002)(86362001)(26005)(36906005)(16526019)(55016002)(6666004)(36860700001)(478600001)(316002)(47076005)(6286002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2021 17:57:23.6457 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e87e45bf-158a-4653-8c4d-08d90f261228 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: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4231 Subject: [dpdk-dev] [PATCH v3 14/15] common/mlx5: support register write access 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: Dekel Peled This patch adds support of write operation to NIC registers. Signed-off-by: Dekel Peled Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_devx_cmds.c | 67 +++++++++++++++++++++++++++- drivers/common/mlx5/mlx5_devx_cmds.h | 4 ++ drivers/common/mlx5/version.map | 1 + 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index c0a0853c3a..0b421933ce 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -12,7 +12,6 @@ #include "mlx5_common_log.h" #include "mlx5_malloc.h" - /** * Perform read access to the registers. Reads data from register * and writes ones to the specified buffer. @@ -61,7 +60,7 @@ mlx5_devx_cmd_register_read(void *ctx, uint16_t reg_id, uint32_t arg, if (status) { int syndrome = MLX5_GET(access_register_out, out, syndrome); - DRV_LOG(DEBUG, "Failed to access NIC register 0x%X, " + DRV_LOG(DEBUG, "Failed to read access NIC register 0x%X, " "status %x, syndrome = %x", reg_id, status, syndrome); return -1; @@ -74,6 +73,70 @@ mlx5_devx_cmd_register_read(void *ctx, uint16_t reg_id, uint32_t arg, return rc; } +/** + * Perform write access to the registers. + * + * @param[in] ctx + * Context returned from mlx5 open_device() glue function. + * @param[in] reg_id + * Register identifier according to the PRM. + * @param[in] arg + * Register access auxiliary parameter according to the PRM. + * @param[out] data + * Pointer to the buffer containing data to write. + * @param[in] dw_cnt + * Buffer size in double words (32bit units). + * + * @return + * 0 on success, a negative value otherwise. + */ +int +mlx5_devx_cmd_register_write(void *ctx, uint16_t reg_id, uint32_t arg, + uint32_t *data, uint32_t dw_cnt) +{ + uint32_t in[MLX5_ST_SZ_DW(access_register_in) + + MLX5_ACCESS_REGISTER_DATA_DWORD_MAX] = {0}; + uint32_t out[MLX5_ST_SZ_DW(access_register_out)] = {0}; + int status, rc; + void *ptr; + + MLX5_ASSERT(data && dw_cnt); + MLX5_ASSERT(dw_cnt <= MLX5_ACCESS_REGISTER_DATA_DWORD_MAX); + if (dw_cnt > MLX5_ACCESS_REGISTER_DATA_DWORD_MAX) { + DRV_LOG(ERR, "Data to write exceeds max size"); + return -1; + } + MLX5_SET(access_register_in, in, opcode, + MLX5_CMD_OP_ACCESS_REGISTER_USER); + MLX5_SET(access_register_in, in, op_mod, + MLX5_ACCESS_REGISTER_IN_OP_MOD_WRITE); + MLX5_SET(access_register_in, in, register_id, reg_id); + MLX5_SET(access_register_in, in, argument, arg); + ptr = MLX5_ADDR_OF(access_register_in, in, register_data); + memcpy(ptr, data, dw_cnt * sizeof(uint32_t)); + rc = mlx5_glue->devx_general_cmd(ctx, in, sizeof(in), out, sizeof(out)); + + rc = mlx5_glue->devx_general_cmd(ctx, in, + MLX5_ST_SZ_BYTES(access_register_in) + + dw_cnt * sizeof(uint32_t), + out, sizeof(out)); + if (rc) + goto error; + status = MLX5_GET(access_register_out, out, status); + if (status) { + int syndrome = MLX5_GET(access_register_out, out, syndrome); + + DRV_LOG(DEBUG, "Failed to write access NIC register 0x%X, " + "status %x, syndrome = %x", + reg_id, status, syndrome); + return -1; + } + return 0; +error: + rc = (rc > 0) ? -rc : rc; + return rc; +} + /** * Allocate flow counters via devx interface. * diff --git a/drivers/common/mlx5/mlx5_devx_cmds.h b/drivers/common/mlx5/mlx5_devx_cmds.h index 811e7a1462..ce570ad28a 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.h +++ b/drivers/common/mlx5/mlx5_devx_cmds.h @@ -566,6 +566,10 @@ __rte_internal int mlx5_devx_cmd_register_read(void *ctx, uint16_t reg_id, uint32_t arg, uint32_t *data, uint32_t dw_cnt); +__rte_internal +int mlx5_devx_cmd_register_write(void *ctx, uint16_t reg_id, + uint32_t arg, uint32_t *data, uint32_t dw_cnt); + __rte_internal struct mlx5_devx_obj * mlx5_devx_cmd_create_geneve_tlv_option(void *ctx, diff --git a/drivers/common/mlx5/version.map b/drivers/common/mlx5/version.map index 04b2179b2c..c630696213 100644 --- a/drivers/common/mlx5/version.map +++ b/drivers/common/mlx5/version.map @@ -53,6 +53,7 @@ INTERNAL { mlx5_devx_cmd_queue_counter_alloc; # WINDOWS_NO_EXPORT mlx5_devx_cmd_queue_counter_query; # WINDOWS_NO_EXPORT mlx5_devx_cmd_register_read; + mlx5_devx_cmd_register_write; mlx5_devx_cmd_wq_query; # WINDOWS_NO_EXPORT mlx5_devx_cq_create; -- 2.25.1