From patchwork Tue May 23 20:54:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Rameshbabu X-Patchwork-Id: 13252923 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9B15A958 for ; Tue, 23 May 2023 20:56:27 +0000 (UTC) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2068.outbound.protection.outlook.com [40.107.94.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F590186 for ; Tue, 23 May 2023 13:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D8+s654KYOjySusDJ73UM7DQ6afYG32Gcwu/AzXbqJO3Ao/7JMVHsOTczxjmR/vstVDAdBIeuuetcnmZmmG+9q7Fr8x3fElOF19voFBWHSDpi7K+EAPQod6ImeY0kxvLotjqbjtbjWec/zAVQPz4J6/ZMmZ9n6OSafD/Rd08t9+8BI+mKMYOgUoNJX9oUA1fllNIs3s1VNk9Z7CjDEamz024zz685g7+xpD6ZnvwfPQF4KUOTXLhZVD/hEbBEtYokQWj3Igayr1bUxOzhVSounnb+JkzgqS3p9IgvYuQDjdQjUFGSvv++fuDtNzqegWKA6C7Tp/Mv4rbNbsrD0wKAQ== 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=5HJp3wiVtMq4ICjqFWFw/dI7l939iD/xx5s18c8SOg0=; b=YU4PNW3AqNkNn40CLy5Ztn1TA0fAdhBgzSYymPj5QgDfVknkia8RjXsk8u+orNGlsUhkFW6cUUTjkvcIT22DDIgFNRCbB8d5TN3Xk9+eqnb/X27x3mbneTQoCO8zmw08KPbyDWmcs0u/HLygDHfi2lpvbfL2QlxZXuglisdpjKMTZyGnbuk5okvi8yxvunor34lmx9pw/PJvNOzzki0S+YXGVTe6e8SGJnD9e2HkS5tLPLO5RcVKwDI8YQh1cGTDUHsZDd6mvklis9xHum2C1xAxBYnFsYlxzK9+MkInk8AyLyPwPJzUFLnURdBOOVeKAI2V1A15gDuSrlw/VnCZug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; 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=5HJp3wiVtMq4ICjqFWFw/dI7l939iD/xx5s18c8SOg0=; b=aihNk0nnMoC1EvUk+sKtASjneV2xx57ZUMTtuDk3VYUsGSevfQuHseV/W4Ovo/R88kMEXWHjPAn94T5QFahNCU5lNkrnJg8FfKmfmkIY65lR6GbPRkgo0447xkkZ7uONlZZck+OaRUIv3W5hA0pv+T3Hd8YES6ERR2Fvj3g6CTgExzcLMp5ymNe+qRNpU6TISk3NI+4aUzTx+eW6CwfZbZAOMYS4BQj1dB1bHl98vbl3pbVmoCF7OZT293wYEKCQ9mwYDiBlkwCSLm9wgR75OkFO8w8GMP9llxUXwT1lw3pQzNkQGWYaTUdXQrHeVYUBPl1CdfbLVdSQgODJmVi/hA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) by DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.29; Tue, 23 May 2023 20:55:48 +0000 Received: from BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::f3d4:f48a:1bfc:dbf1]) by BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::f3d4:f48a:1bfc:dbf1%5]) with mapi id 15.20.6411.019; Tue, 23 May 2023 20:55:48 +0000 From: Rahul Rameshbabu To: netdev@vger.kernel.org Cc: "David S. Miller" , Jacob Keller , Gal Pressman , Tariq Toukan , Saeed Mahameed , Rahul Rameshbabu , Saeed Mahameed , Richard Cochran Subject: [PATCH net-next v2 6/9] net/mlx5: Add .getmaxphase ptp_clock_info callback Date: Tue, 23 May 2023 13:54:37 -0700 Message-Id: <20230523205440.326934-7-rrameshbabu@nvidia.com> X-Mailer: git-send-email 2.38.4 In-Reply-To: <20230523205440.326934-1-rrameshbabu@nvidia.com> References: <20230523205440.326934-1-rrameshbabu@nvidia.com> X-ClientProxiedBy: BYAPR02CA0041.namprd02.prod.outlook.com (2603:10b6:a03:54::18) To BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB2743:EE_|DM6PR12MB4337:EE_ X-MS-Office365-Filtering-Correlation-Id: c225432a-4cb1-4796-d5a7-08db5bd015b7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hy5ZmWlmzYAyHhZg8QD9gb9xK6BHR6nz3BVK+8Ch9ZQej6ctUNTIWBzlU9RSduu2LbNlLGKZ8jZT8SWj9OFAekr4TA+mswnBg/1iX8UK6BEgbfp/debDGmYs6bsF/ktAL1oHejp/MYk0poXKWNUc8yB48Q19rKWsJkbReO8SDFiLdoIPWRckzndP04HE0VrcgDVz3+CEU8DC4y+5zWnEZ4CAIAdhYz+3Vidtrb8vnutoZ1zw4u65a0QT9OhF/GeWlm0qqTQt1lORnWaM2SL0v9wBIHUvrpw3prgEOLNSBX1SLWIEwSx9dvEUL77ibsdi6l3PZME364Pn5ha3W6m8ddjAIUabGwp6J6ttPv+FOS63JgHBue4oD9UejZ9RsBPdE90jk3vvxVZYrtNsd5L9pyyVtdRZu1rBih7gBF3NSiL2VpDwLHLznJSaKZUoyHB5UzAcFTwIFWbQza5XyPjNfN6fWNalCrWbDfEKOt/qlrXzbqlvha2q30bZTwuvZ2IEPF761TMw2YoaDiGQSWRSvCiegx8u+7S/v1mPJhzI/WJkeCEAUH11DQPFfb/5FeFeMNtOgrLEGNpUFK4wk3Am0ndz/ue/SM9FJjYiECZ8WEo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2743.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(376002)(366004)(396003)(136003)(39860400002)(451199021)(26005)(186003)(1076003)(6512007)(6506007)(2616005)(36756003)(83380400001)(2906002)(41300700001)(6486002)(316002)(54906003)(6666004)(38100700002)(478600001)(66476007)(66946007)(66556008)(6916009)(4326008)(86362001)(8936002)(8676002)(5660300002)(142923001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mcg30WVo2F7gPsd7no9WVoeyjX5RaL15HnZJmUBdyABbUSx9XAgtC7ll5dnEZNjfZp+bTMJqQ5wQ1rn9M4Xjc2XgSdk/yuea+mn+1gRhhJOC4JqbSd229Sa8QVPp7cK3Xbq8LKnnSCgw+wmVakjLt7/FRx0R40wQLYpQTQBnv+KIrMtUEW5+gg1kiveOqBwrT+OPQCc6f+fqCeZop2VQ/ee+XybiuNxLDah5GZHyYPPUBywAYW6dawogJY412ItRg3IWhpIY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ZboLwokxBu8VDRS95fRdJnNa0rCE+UPZ19HtpfQe0F1doPZmCxgxs3NWNtJP3+OBLd1twX/vQ+cvXXVkvKI4+ua+WvDBEZr/l5MigjdTafLfkPpMJpXZshOnET6yKDEVuylfq86rYEsqxML6GyTwu3LC+Fw+sUnWq/cYQSPDjetG7OuC/8DNaqZAd/v9dCyLcD7OSnhE2n0IDFqt3hVDY+yOjkFPQDc/k1WcmvunTG6bsetDCGFAbM6D8PyDlJ4tcE5N/sS8QKy8VJwhleOoLVA== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: c225432a-4cb1-4796-d5a7-08db5bd015b7 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2743.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 May 2023 20:55:48.0434 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IcROGRs+k426nV4kyfJhPeGYRrdixueJZoPrxksFQC7MusjyhGv9LFIf/4Th7S6StIlTCZ27Zv5qqDaPar5/IA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4337 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Implement .getmaxphase callback of ptp_clock_info in mlx5 driver. No longer do a range check in .adjphase callback implementation. Handled by the ptp stack. Cc: Saeed Mahameed Signed-off-by: Rahul Rameshbabu Acked-by: Richard Cochran --- .../ethernet/mellanox/mlx5/core/lib/clock.c | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index 932fbc843c69..973babfaff25 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c @@ -93,17 +93,23 @@ static bool mlx5_modify_mtutc_allowed(struct mlx5_core_dev *mdev) return MLX5_CAP_MCAM_FEATURE(mdev, ptpcyc2realtime_modify); } -static bool mlx5_is_mtutc_time_adj_cap(struct mlx5_core_dev *mdev, s64 delta) +static s32 mlx5_ptp_getmaxphase(struct ptp_clock_info *ptp) { - s64 min = MLX5_MTUTC_OPERATION_ADJUST_TIME_MIN; - s64 max = MLX5_MTUTC_OPERATION_ADJUST_TIME_MAX; + struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, ptp_info); + struct mlx5_core_dev *mdev; - if (MLX5_CAP_MCAM_FEATURE(mdev, mtutc_time_adjustment_extended_range)) { - min = MLX5_MTUTC_OPERATION_ADJUST_TIME_EXTENDED_MIN; - max = MLX5_MTUTC_OPERATION_ADJUST_TIME_EXTENDED_MAX; - } + mdev = container_of(clock, struct mlx5_core_dev, clock); + + return MLX5_CAP_MCAM_FEATURE(mdev, mtutc_time_adjustment_extended_range) ? + MLX5_MTUTC_OPERATION_ADJUST_TIME_EXTENDED_MAX : + MLX5_MTUTC_OPERATION_ADJUST_TIME_MAX; +} + +static bool mlx5_is_mtutc_time_adj_cap(struct mlx5_core_dev *mdev, s64 delta) +{ + s64 max = mlx5_ptp_getmaxphase(&mdev->clock.ptp_info); - if (delta < min || delta > max) + if (delta < -max || delta > max) return false; return true; @@ -351,14 +357,6 @@ static int mlx5_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) static int mlx5_ptp_adjphase(struct ptp_clock_info *ptp, s32 delta) { - struct mlx5_clock *clock = container_of(ptp, struct mlx5_clock, ptp_info); - struct mlx5_core_dev *mdev; - - mdev = container_of(clock, struct mlx5_core_dev, clock); - - if (!mlx5_is_mtutc_time_adj_cap(mdev, delta)) - return -ERANGE; - return mlx5_ptp_adjtime(ptp, delta); } @@ -734,6 +732,7 @@ static const struct ptp_clock_info mlx5_ptp_clock_info = { .pps = 0, .adjfine = mlx5_ptp_adjfine, .adjphase = mlx5_ptp_adjphase, + .getmaxphase = mlx5_ptp_getmaxphase, .adjtime = mlx5_ptp_adjtime, .gettimex64 = mlx5_ptp_gettimex, .settime64 = mlx5_ptp_settime,