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 02B2FA00BE; Sun, 10 Apr 2022 12:31:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E7B2C410EA; Sun, 10 Apr 2022 12:31:41 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2050.outbound.protection.outlook.com [40.107.223.50]) by mails.dpdk.org (Postfix) with ESMTP id 3F7414068C for ; Sun, 10 Apr 2022 12:31:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NlxKdx0ewwLAJxeix8jE/g7tgIE/VDFElcOtfvWMUaaI7CSfqCPX6wUfnwa2JEq+KWZ5opEmsfU7Yv5XOQKmHFixgIX2Y0ovXN9C4+v7vICznfHbKgLgf0L0aZ/697ScKXJoSmh7Ulq3HtvcxklBg0VN+DOkBgVhFTUEBTwaKWCZoWpEIM2CAqZi4bE0I3CW9ww+JNHFTHB7QZyw2xOsIm40/wnnQ8KDDQ2S4Q41oH4vTnlBmSO7/EzFMlnlJgzXvz46pJYDszZRARIIc4+zaraBjOi72Bi1TRzjEh3AvR4F0Wp8XymFKd32L4C1IXHlcuZYi5E+dLFSJwrsFO5G9w== 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=peymd2qSlRNvBvjfIJfRmgNrr+jxP4OXZkAwu3XA1aE=; b=XAX25qc8jC6KEssfPbta0btg6r1AgglXVl3d+gCqrRvF25qVTOMyGrsASlhsB6McZV+JkuD8m6jOWsL/zF1jUHrAcUwTQRjKVrjsezwnsqDyJhv909lX6HMp61bk3472taYij9e74rw2cuJ0nsXhUD/1nA6Ukc+vrGNfrwqkqYr84JJKjoJL+RQlbKVIPHZ8vHE75g9UQNHhZMlJMouMhlE+Yck0X8y+FCKTte+SY7/7VREmX2bapbJEbxLo1UOJxvxXbsmIxmBThqXVmM5iX3eiQYJLoEi1+w1u2I7P7A4dRiGYVeuVuL7vRr/aTV4IkbYQkccNEP3je5goPGLTmQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) smtp.rcpttodomain=monjalon.net 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=peymd2qSlRNvBvjfIJfRmgNrr+jxP4OXZkAwu3XA1aE=; b=oFwpwByrb8pujsB4UZ8Ty8KIDh7Z3WaCk9zoYR82KpjtOQ5WKj7gfhGo+q39FVHLxnXMmi7DXtwbEgMZVk5XFeXV4kzZyL39hW4xrY/uOsRf9FdUWp9YPxCPEl9z6ls39GvsUcSwVhogQfZfQuJQzyIhTut1sHj8q7/HhC3WdPxL3KN54QuYqks2oCFzrV/1hB0qXFy4YSj2xGx4BssR/7Xs25gAJeqPnWswf1/GgPO80rm6jXi1xm4YS1fx50NBILylR5t+jlLO5lptT3f+78WOo/or2jfCHueUk6bJb8+BB8lTEaeSm45Dn7EHxhtt0DkzWzU3jTci52dFs9T6Gw== Received: from DM6PR14CA0066.namprd14.prod.outlook.com (2603:10b6:5:18f::43) by CH2PR12MB3685.namprd12.prod.outlook.com (2603:10b6:610:2d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.29; Sun, 10 Apr 2022 10:31:38 +0000 Received: from DM6NAM11FT022.eop-nam11.prod.protection.outlook.com (2603:10b6:5:18f:cafe::1) by DM6PR14CA0066.outlook.office365.com (2603:10b6:5:18f::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22 via Frontend Transport; Sun, 10 Apr 2022 10:31:38 +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 DM6NAM11FT022.mail.protection.outlook.com (10.13.172.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5144.20 via Frontend Transport; Sun, 10 Apr 2022 10:31:38 +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.32; Sun, 10 Apr 2022 10:31:32 +0000 Received: from nvidia.com (10.126.230.35) 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.22; Sun, 10 Apr 2022 03:31:29 -0700 From: Adham Masarwah To: CC: , , , , , Subject: [PATCH 2/2] net/mlx5: add support for set and get MTU in Windows Date: Sun, 10 Apr 2022 13:31:07 +0300 Message-ID: <20220410103107.66964-3-adham@nvidia.com> X-Mailer: git-send-email 2.16.1.windows.4 In-Reply-To: <20220410103107.66964-2-adham@nvidia.com> References: <20220410103107.66964-2-adham@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 65e4d35e-4338-4d36-022e-08da1add4b99 X-MS-TrafficTypeDiagnostic: CH2PR12MB3685:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TnMKdpiivdKsmO1Gl14m7FUhlIjJITa1wkT4joZrxyAIxxHPncAbKrGVmKXAexsPneD7k0EtLHjaDbwmh7PqR9E8kyMfgBYlj9U/hzAIe48xdTn5HA99xB0+xfi07glSy+LaVI1gpYQMk0AvJXbuCQbwF/fEYhVIAoFISm5ERpfOpduuc9QFRTOOjKCNhsVSS2Z71ZGZcwPaDMrGTuFqY2hSr17iwu/9UfBye/qweeGOHBHway1wFoASoiZzciqvIDHyH5LP/cDT2ouTeCCkAJ/h0SC7kIVNYUGu++RkdlJ+DvkeD6LuJMoI8xJ0t7JcRC36c5/0803t+JyFTH+K+GMTrqBQcxREMJkJSLaJ24Wi3HL0l2fJn6HWhaX8GhrfdnSRGEN+U1ioQv0VyNGUzEnjFK6254HLiQeHb09c9Z04firaMhq9+Tn8INAtDrArErx1J/E3DlpNgz1o9E+sGwxOYdhd36euwgQqX7c8nS3tAybVZ1QCSZK6QGz8TUGnTY2ILhFsinglzuAgE0PWAIwCpthRAin4N0Fhz+HN2KzO9kOrgqwSgbXrHYackHQr37MwyBuFtAazfjfMYGhad4oUcCQbNBR0BOfhhJ9pTvlr16eyLtms64Wmo+WrP6b6kO7+RBgN5mMndDvmvAI0JINsdGYqj6cpy7Wvjv7LKwkA3Nwu2ZgMyeKnOxBCrI9wifFsAs5pCLZXU6cs1rStvg== 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)(83380400001)(508600001)(8936002)(26005)(82310400005)(186003)(16526019)(336012)(47076005)(5660300002)(2906002)(36756003)(40460700003)(36860700001)(55016003)(426003)(1076003)(316002)(70586007)(107886003)(70206006)(86362001)(6916009)(2616005)(4326008)(8676002)(54906003)(7696005)(6286002)(356005)(6666004)(81166007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2022 10:31:38.3353 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65e4d35e-4338-4d36-022e-08da1add4b99 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: DM6NAM11FT022.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3685 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 Mlx5Devx library has new API's for setting and getting MTU. Added new glue functions that wrap the new mlx5devx lib API's. Implemented the os_ethdev callbacks to use the new glue functions in Windows. Signed-off-by: Adham Masarwah Tested-by: Idan Hackmon Acked-by: Matan Azard --- drivers/common/mlx5/windows/mlx5_glue.c | 55 +++++++++++++++++++++++++++++++ drivers/common/mlx5/windows/mlx5_glue.h | 2 ++ drivers/net/mlx5/windows/mlx5_ethdev_os.c | 31 ++++++++++++++--- 3 files changed, 84 insertions(+), 4 deletions(-) diff --git a/drivers/common/mlx5/windows/mlx5_glue.c b/drivers/common/mlx5/windows/mlx5_glue.c index 73d63ffd98..6935811bf4 100644 --- a/drivers/common/mlx5/windows/mlx5_glue.c +++ b/drivers/common/mlx5/windows/mlx5_glue.c @@ -358,6 +358,59 @@ mlx5_glue_devx_set_promisc_vport(void *ctx, uint32_t promisc_type, uint8_t f_ena #endif } +static int +mlx5_glue_devx_get_mtu(void *ctx, uint32_t *mtu) +{ + int err = 0; + struct mlx5_context *mlx5_ctx; + + if (!ctx) { + errno = EINVAL; + return errno; + } + mlx5_ctx = (struct mlx5_context *)ctx; +#ifdef HAVE_DEVX_SET_GET_MTU_SUPPORT + err = devx_get_mtu(mlx5_ctx->devx_ctx, mtu); + if (err) { + errno = err; + return errno; + } +#else + *mtu = mlx5_ctx->mlx5_dev.mtu_bytes; +#endif + + return err; +} + +static int +mlx5_glue_devx_set_mtu(void *ctx, uint32_t mtu) +{ +#ifdef HAVE_DEVX_SET_GET_MTU_SUPPORT + struct mlx5_context *mlx5_ctx; + int err; + + if (!ctx) { + errno = EINVAL; + return errno; + } + mlx5_ctx = (struct mlx5_context *)ctx; + err = devx_set_mtu(mlx5_ctx->devx_ctx, mtu); + if (err) { + errno = err; + return errno; + } + return 0; +#else + (void)mtu; + (void)ctx; + DRV_LOG(WARNING, "%s: is not supported", __func__); + return -ENOTSUP; +#endif + +} + + + alignas(RTE_CACHE_LINE_SIZE) const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){ .version = MLX5_GLUE_VERSION, @@ -382,4 +435,6 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue){ .query_rt_values = mlx5_glue_query_rt_values, .devx_init_showdown_event = mlx5_glue_devx_init_showdown_event, .devx_set_promisc_vport = mlx5_glue_devx_set_promisc_vport, + .devx_get_mtu = mlx5_glue_devx_get_mtu, + .devx_set_mtu = mlx5_glue_devx_set_mtu, }; diff --git a/drivers/common/mlx5/windows/mlx5_glue.h b/drivers/common/mlx5/windows/mlx5_glue.h index eae8070b3f..5ba324ebc4 100644 --- a/drivers/common/mlx5/windows/mlx5_glue.h +++ b/drivers/common/mlx5/windows/mlx5_glue.h @@ -93,6 +93,8 @@ struct mlx5_glue { int (*query_rt_values)(void *ctx, void *devx_clock); int (*devx_init_showdown_event)(void *ctx); int (*devx_set_promisc_vport)(void *ctx, uint32_t promisc_type, uint8_t f_enable); + int (*devx_get_mtu)(void *ctx, uint32_t *mtu); + int (*devx_set_mtu)(void *ctx, uint32_t mtu); }; extern const struct mlx5_glue *mlx5_glue; diff --git a/drivers/net/mlx5/windows/mlx5_ethdev_os.c b/drivers/net/mlx5/windows/mlx5_ethdev_os.c index c6315ce368..f97526580d 100644 --- a/drivers/net/mlx5/windows/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/windows/mlx5_ethdev_os.c @@ -85,6 +85,8 @@ mlx5_get_ifname(const struct rte_eth_dev *dev, char (*ifname)[MLX5_NAMESIZE]) int mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu) { + int err; + uint32_t curr_mtu; struct mlx5_priv *priv; mlx5_context_st *context_obj; @@ -94,7 +96,14 @@ mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu) } priv = dev->data->dev_private; context_obj = (mlx5_context_st *)priv->sh->cdev->ctx; - *mtu = context_obj->mlx5_dev.mtu_bytes; + + err = mlx5_glue->devx_get_mtu(context_obj, &curr_mtu); + if (err != 0) { + DRV_LOG(WARNING, "Could not get the MTU!"); + return err; + } + *mtu = (uint16_t)curr_mtu; + return 0; } @@ -112,9 +121,23 @@ mlx5_get_mtu(struct rte_eth_dev *dev, uint16_t *mtu) int mlx5_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) { - RTE_SET_USED(dev); - RTE_SET_USED(mtu); - return -ENOTSUP; + int err; + struct mlx5_priv *priv; + mlx5_context_st *context_obj; + + if (!dev) { + rte_errno = EINVAL; + return -rte_errno; + } + priv = dev->data->dev_private; + context_obj = (mlx5_context_st *)priv->sh->cdev->ctx; + + err = mlx5_glue->devx_set_mtu(context_obj, mtu); + if (err != 0) { + DRV_LOG(WARNING, "Could not set the MTU!"); + return err; + } + return 0; } /* -- 2.16.1.windows.4