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 9BB9FA00C4; Mon, 14 Feb 2022 10:36:31 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 89A4D411CE; Mon, 14 Feb 2022 10:35:49 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2078.outbound.protection.outlook.com [40.107.95.78]) by mails.dpdk.org (Postfix) with ESMTP id 99B52411CE for ; Mon, 14 Feb 2022 10:35:48 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h5jm5f/6AxZdwM3/NTKxWzmybGebjnDMRye2SNHC86QQTELIbhpeQHfznfTkl5vEk7xFPbXl4hINAbnIdHqDmCUc+9qeKMmPEYdBYn+jjAhXt8CV1Z0J1jywOTFn0PX8jWqNRIPPqDKQXtnYTK9qyCu6FF6hrYPZgWRaqD8kp9fvdVBntiK3TvPQFfQB/F2QPYn/dYSl0xImhgql6Rt6uj8lQ4PzlVPxp+AWs+RgeodKpdi4+J/Ta2w1cit2TIXFyb9jn4Sk2FI1Jl1MIsnCVCMHvt6xTXWhEnIeJxwtoTwt3hL/tyb5OmmhSt5yd8r4r29tvf8/AmlXMike6fDRaA== 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=3+qOawLON70/0KWnUGoYwOMozGWmlPkB2K+e85LVhJI=; b=kj0dxHCe/VxRwXj8XxZweONlrf4d/pkfrqxA61wkY2GhzRi4QJeqg/wIN5u5tSwA9ZMEGJxKqmqR6aWTLVPrws9ujNJNPx5p/lji5tydI6MaNVTL3XMaw5ARMF8yXVdIx17ekNrZvQea8WEPaGwJrxExAjR750XyPrPIfajMOkGGqbaZLL0lZYbzk4pEHQmS7PJYMcGbZPXVLEXVA3ZUhwFrImAJAjouy+WUn6g1VT0zYrMOYrb8vNkZEGQsfbol+Vn/W3cHGhsyXDEhmH27j0Sq45COk9j5HeCH9MEno/bZY7OujL91YYwD2IvgCRzSF26GMqd46muHeKvlir8/gg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=3+qOawLON70/0KWnUGoYwOMozGWmlPkB2K+e85LVhJI=; b=ie3Rkb9Q6ZbnHBJYS4yj9ZB8o+Gzp//pxgaSIOmLg4moc91IoXoMzn2Fh8XElo2rb881WxY4TQL0NRgKHiPc+S7l6OST1ofUYlpg6MEzaH4kTsiwNiYAhNX/4bKk/Ez/J+mEd2O3mlHb+pfNX/4TklfEPEiZsOxpEaYXqI/PpeVRyYLQ67caGf1IZNcGmb1z7aIADXR9gKiyCjnh49UCi+s1Nbxs1vj6ejEcQr0hx8XG/YF7ySWJ6rVkbWHQxHtW0wZ+qKlH2rB+rFEboYRNskB+8Kn0F4jwmEj+smUO7tf8JwkhxNWP5FZwK6T/kM+TjFqkD0iEiGA1KWo9NkntQQ== Received: from DS7PR06CA0033.namprd06.prod.outlook.com (2603:10b6:8:54::15) by CY4PR1201MB2500.namprd12.prod.outlook.com (2603:10b6:903:d0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Mon, 14 Feb 2022 09:35:47 +0000 Received: from DM6NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:8:54:cafe::9e) by DS7PR06CA0033.outlook.office365.com (2603:10b6:8:54::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.13 via Frontend Transport; Mon, 14 Feb 2022 09:35:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.235) by DM6NAM11FT010.mail.protection.outlook.com (10.13.172.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 09:35:46 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 09:35:46 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Mon, 14 Feb 2022 01:35:45 -0800 Received: from nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9 via Frontend Transport; Mon, 14 Feb 2022 01:35:43 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Subject: [PATCH v2 11/20] net/mlx5: share realtime timestamp configure Date: Mon, 14 Feb 2022 11:35:02 +0200 Message-ID: <20220214093511.1592698-12-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220214093511.1592698-1-michaelba@nvidia.com> References: <20220127153950.812953-1-michaelba@nvidia.com> <20220214093511.1592698-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bf26809e-0c6a-4fc4-195f-08d9ef9d6117 X-MS-TrafficTypeDiagnostic: CY4PR1201MB2500:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6pY7ZJXNtCkeBtaTkn5H6lxVrWYLrgFvnle14OQDtqhfcEGpvm5gVbRwOyPC/H/UyW+Fs5IAu6EkdIrc/Re+MSEkp3a/ia3AWdHbNyGETV6Kcu5rGmR2SfXFQENXtfWnzeI1F5/HTsLaIQEuelQVbRXsnc18ItprPwQy8sc8gMg8Kbs2vptC+WLXdSoYF30Pm6OBhcYU/skxUX1ozJi3tWHOYJ8yvITx4KqOEZj4Npd4x3fgW3Q7mPLKBPYa1uQ45cUzC2hheXwISYayUrGQpTZRuuhjJTsOQDA4Ili8cmg7JtAWDCSUHbbjcHs5UZZ5HwpAFD/cCBqHQr0ntiRmoMY3kZ1SoObLImbcMXx5QZLqU9d/Pb/D8ASyOZkmLQMoXiCe04/xUdtenPNBxmGWfzB2K0sw8xjzRrYz64BWHFaD5pmWK335bNHWeE3vvJhjTlqQDj703fGAuBiQx+I7qVXXxgN2uzOF7oi1qXXJlXBxezjTx7JBa3xC1X4Sl74QtgYWnrdeGj25j1zCLtn0t6HgTDhZMmM3kxZnCPPatwduFDdriUQJcML2/vYsbAXyRd8J8VLdUeFTpxn2ZW1MyIvfRds4fY1J5jwzHLJypBUBPLrfoYfnfBoFBGdp50zj1f+6rVWta9H0GlFj2VWakIlfxkoXuTFTKOy/k1RSGNjt4GUX4jD/+wid3owpGJ1gHuAa3bbkD9KW0LeNf3tO7w== X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(40460700003)(508600001)(81166007)(82310400004)(83380400001)(8676002)(356005)(6286002)(336012)(426003)(5660300002)(86362001)(8936002)(36860700001)(4326008)(2616005)(70206006)(47076005)(2906002)(36756003)(54906003)(26005)(316002)(55016003)(6666004)(107886003)(186003)(7696005)(6916009)(70586007)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 09:35:46.6193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf26809e-0c6a-4fc4-195f-08d9ef9d6117 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB2500 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 The realtime timestamp configure work for Linux as same as Windows. This patch removes it to the function implemented in the folder shared between the operating systems, removing the duplication. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 23 ++----------------- drivers/net/mlx5/mlx5.c | 37 ++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5.h | 3 +++ drivers/net/mlx5/windows/mlx5_os.c | 22 +----------------- 4 files changed, 43 insertions(+), 42 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index d1bf89922e..bee055772b 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1516,27 +1516,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->dev_port); } } - if (sh->cdev->config.devx) { - uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)]; - - err = hca_attr->access_register_user ? - mlx5_devx_cmd_register_read - (sh->cdev->ctx, MLX5_REGISTER_ID_MTUTC, 0, - reg, MLX5_ST_SZ_DW(register_mtutc)) : ENOTSUP; - if (!err) { - uint32_t ts_mode; - - /* MTUTC register is read successfully. */ - ts_mode = MLX5_GET(register_mtutc, reg, - time_stamp_mode); - if (ts_mode == MLX5_MTUTC_TIMESTAMP_MODE_REAL_TIME) - config->rt_timestamp = 1; - } else { - /* Kernel does not support register reading. */ - if (hca_attr->dev_freq_khz == (NS_PER_S / MS_PER_S)) - config->rt_timestamp = 1; - } - } + if (sh->cdev->config.devx) + mlx5_rt_timestamp_config(sh, config, hca_attr); /* * If HW has bug working with tunnel packet decapsulation and * scatter FCS, and decapsulation is needed, clear the hw_fcs_strip diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 34b3f3f137..4884198509 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1129,6 +1129,43 @@ mlx5_setup_tis(struct mlx5_dev_ctx_shared *sh) return 0; } +/** + * Configure realtime timestamp format. + * + * @param sh + * Pointer to mlx5_dev_ctx_shared object. + * @param config + * Device configuration parameters. + * @param hca_attr + * Pointer to DevX HCA capabilities structure. + */ +void +mlx5_rt_timestamp_config(struct mlx5_dev_ctx_shared *sh, + struct mlx5_dev_config *config, + struct mlx5_hca_attr *hca_attr) +{ + uint32_t dw_cnt = MLX5_ST_SZ_DW(register_mtutc); + uint32_t reg[dw_cnt]; + int ret = ENOTSUP; + + if (hca_attr->access_register_user) + ret = mlx5_devx_cmd_register_read(sh->cdev->ctx, + MLX5_REGISTER_ID_MTUTC, 0, + reg, dw_cnt); + if (!ret) { + uint32_t ts_mode; + + /* MTUTC register is read successfully. */ + ts_mode = MLX5_GET(register_mtutc, reg, time_stamp_mode); + if (ts_mode == MLX5_MTUTC_TIMESTAMP_MODE_REAL_TIME) + config->rt_timestamp = 1; + } else { + /* Kernel does not support register reading. */ + if (hca_attr->dev_freq_khz == (NS_PER_S / MS_PER_S)) + config->rt_timestamp = 1; + } +} + /** * Allocate shared device context. If there is multiport device the * master and representors will share this context, if there is single diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 6bc7a34f60..0f90d757e9 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1517,6 +1517,9 @@ void mlx5_age_event_prepare(struct mlx5_dev_ctx_shared *sh); port_id < RTE_MAX_ETHPORTS; \ port_id = mlx5_eth_find_next(port_id + 1, dev)) int mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs); +void mlx5_rt_timestamp_config(struct mlx5_dev_ctx_shared *sh, + struct mlx5_dev_config *config, + struct mlx5_hca_attr *hca_attr); struct mlx5_dev_ctx_shared * mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, const struct mlx5_dev_config *config); diff --git a/drivers/net/mlx5/windows/mlx5_os.c b/drivers/net/mlx5/windows/mlx5_os.c index cca99f3eea..cf0819e013 100644 --- a/drivers/net/mlx5/windows/mlx5_os.c +++ b/drivers/net/mlx5/windows/mlx5_os.c @@ -483,27 +483,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, DRV_LOG(DEBUG, "VLAN stripping is %ssupported", (config->hw_vlan_strip ? "" : "not ")); config->hw_fcs_strip = hca_attr->scatter_fcs; - } - if (sh->devx) { - uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)]; - - err = hca_attr->access_register_user ? - mlx5_devx_cmd_register_read - (sh->cdev->ctx, MLX5_REGISTER_ID_MTUTC, 0, - reg, MLX5_ST_SZ_DW(register_mtutc)) : ENOTSUP; - if (!err) { - uint32_t ts_mode; - - /* MTUTC register is read successfully. */ - ts_mode = MLX5_GET(register_mtutc, reg, - time_stamp_mode); - if (ts_mode == MLX5_MTUTC_TIMESTAMP_MODE_REAL_TIME) - config->rt_timestamp = 1; - } else { - /* Kernel does not support register reading. */ - if (hca_attr->dev_freq_khz == (NS_PER_S / MS_PER_S)) - config->rt_timestamp = 1; - } + mlx5_rt_timestamp_config(sh, config, hca_attr); } if (config->mprq.enabled) { DRV_LOG(WARNING, "Multi-Packet RQ isn't supported"); -- 2.25.1