Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6142503rwd; Mon, 19 Jun 2023 03:02:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ75wCzQX8kBntXeMRB0k54FhEAbwxEp5Q4XUqA7zuaffcqoNXcFeQAq0IkGX9wAiJICF0Nf X-Received: by 2002:a17:90a:69a2:b0:25b:f9ce:d8df with SMTP id s31-20020a17090a69a200b0025bf9ced8dfmr7274118pjj.8.1687168965422; Mon, 19 Jun 2023 03:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687168965; cv=none; d=google.com; s=arc-20160816; b=vDO9lVdkKqsulDz4Vv1G2Ht7ynHlyvCzIczUaEv/qfDPtAcBhuHN5ZdNKvJLmaZGHr HT4X9b7u84bw/VzAHyHfAQMYjBbGyMKUsx7W/6Q3DBIusJzcaHUAB/vh1wc9Z+iUUeb3 yQbnj1TL2MufAm8wkXeoDYpAM37QPu6qwfZxJTm4wTxmyFFGSAS9YJX/g1n3eaMFF7a8 YyryIsmTkraUznWKAZ1bmJyF8g2/V63NLfrxp85NB9MfCjMS6XeBe8RnwqOAaY8YKCp7 XoTE4yKHb/sz5hNkNiYpNDjzo65CXKAr76kNP8ovWcif8RbdvEQjz3DtyJ+0bipGzstL rryg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aa+Ne3yzN3gF2qIsxrTFWSwhDQhHOpfnyIBApTft1Js=; b=CvNy5h7xDylRV14Gg4y3vWdluzLceECqH8Bx/U33/Yqrya3JYGcVc59yHuL4p6RV0Y 7LD4Xq1Kf9VZs6e7JIdOECbokcxon/kCrudktM8Dc9DxHdHFHIcwYYzuOplWSq0mJ3hL cg3a8pKleMB49ChtBdqUgMV2lHCqD2OdW7eQs9r7sHbG1h5DVzBga/UVVtZx8iCaB/ZF QWaKsvF+Vq0nNJGCqygSlV8keGZYn3VoKM8QHC8r37nmB4VMhZyWBgMYo9hSd5IM8g2R lqOQcvUlvOrjiqTZtsTvRXCx8Dep9h3ASr2TliCya70yjSsblChJI5dbQ2ac/8Wg3xW8 5h0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=D9E4xxsR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a17090ab30b00b0025c21e4bb48si7659099pjr.47.2023.06.19.03.02.26; Mon, 19 Jun 2023 03:02:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=D9E4xxsR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231418AbjFSJjZ (ORCPT + 99 others); Mon, 19 Jun 2023 05:39:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjFSJjX (ORCPT ); Mon, 19 Jun 2023 05:39:23 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 122B3AF; Mon, 19 Jun 2023 02:39:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1687167561; x=1718703561; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=FIVpQIzsj4Ssu2XYiw1BeI1GG1jqR889PGXaA6nQNcg=; b=D9E4xxsRnFp7Y9yaeeAWwx9c8vmA+eeiKFi8jgSeLJLvui3TsNPX48p7 HkWo+GfhnTWkY787+fpP1tOHOhzTclx03qr2an1JlxHOtK65Sbz6402uv hHBWXg6n/+QjnJHC8VzDzl2qpbbC66OkDWJQ3fYG6+orqKj7EALMwUnHp Kejju/18Dc/1tJBCfqY9HzluZqu2HajpiYxAOKlP3cj+l61kPqwgHcaOh T9Ed2wEo6DtKm6hNNDPoi67PR9lnnJVNWJbj7xOKVGdrp0hX0CeHt6hlc +QYiepxSw8x/aoAzvGsrqPLia48w56bZMq5mYhJ5uDbHY6pb5k2Br81PQ g==; X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="230876711" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 19 Jun 2023 02:39:21 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 19 Jun 2023 02:39:16 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 19 Jun 2023 02:39:16 -0700 Date: Mon, 19 Jun 2023 11:39:16 +0200 From: Horatiu Vultur To: Alex Maftei CC: , , , , Subject: Re: [PATCH net 1/2] selftests/ptp: Add -x option for testing PTP_SYS_OFFSET_EXTENDED Message-ID: <20230619093916.xxfkzj576hwz4tjq@soft-dev3-1> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 06/16/2023 23:48, Alex Maftei wrote: Hi Alex, As I can see you will need to send another patch, I have just a small comment bellow. > The -x option (where 'x' stands for eXtended) takes an argument which > represents the number of samples to request from the PTP device. > The help message will display the maximum number of samples allowed. > Providing an invalid argument will also display the maximum number of > samples allowed. > > Signed-off-by: Alex Maftei > --- > tools/testing/selftests/ptp/testptp.c | 42 +++++++++++++++++++++++++-- > 1 file changed, 40 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/ptp/testptp.c b/tools/testing/selftests/ptp/testptp.c > index cfa9562f3cd8..2a99973ffc1b 100644 > --- a/tools/testing/selftests/ptp/testptp.c > +++ b/tools/testing/selftests/ptp/testptp.c > @@ -142,8 +142,9 @@ static void usage(char *progname) > " -S set the system time from the ptp clock time\n" > " -t val shift the ptp clock time by 'val' seconds\n" > " -T val set the ptp clock time to 'val' seconds\n" > + " -x val get an extended ptp clock time with the desired number of samples (up to %d)\n" > " -z test combinations of rising/falling external time stamp flags\n", > - progname); > + progname, PTP_MAX_SAMPLES); > } > > int main(int argc, char *argv[]) > @@ -157,6 +158,7 @@ int main(int argc, char *argv[]) > struct timex tx; > struct ptp_clock_time *pct; > struct ptp_sys_offset *sysoff; > + struct ptp_sys_offset_extended *soe; > > char *progname; > unsigned int i; > @@ -174,6 +176,7 @@ int main(int argc, char *argv[]) > int index = 0; > int list_pins = 0; > int pct_offset = 0; > + int getextended = 0; > int n_samples = 0; > int pin_index = -1, pin_func; > int pps = -1; > @@ -188,7 +191,7 @@ int main(int argc, char *argv[]) > > progname = strrchr(argv[0], '/'); > progname = progname ? 1+progname : argv[0]; > - while (EOF != (c = getopt(argc, argv, "cd:e:f:ghH:i:k:lL:n:p:P:sSt:T:w:z"))) { > + while (EOF != (c = getopt(argc, argv, "cd:e:f:ghH:i:k:lL:n:p:P:sSt:T:w:x:Xz"))) { The 'X' needs to be part of the next patch, as you introduce here only 'x'. > switch (c) { > case 'c': > capabilities = 1; > @@ -250,6 +253,13 @@ int main(int argc, char *argv[]) > case 'w': > pulsewidth = atoi(optarg); > break; > + case 'x': > + getextended = atoi(optarg); > + if (getextended < 1 || getextended > PTP_MAX_SAMPLES) { > + fprintf(stderr, "number of extended timestamp samples must be between 1 and %d; was asked for %d\n", PTP_MAX_SAMPLES, getextended); > + return -1; > + } > + break; > case 'z': > flagtest = 1; > break; > @@ -516,6 +526,34 @@ int main(int argc, char *argv[]) > free(sysoff); > } > > + if (getextended) { > + soe = calloc(1, sizeof(*soe)); > + if (!soe) { > + perror("calloc"); > + return -1; > + } > + > + soe->n_samples = getextended; > + > + if (ioctl(fd, PTP_SYS_OFFSET_EXTENDED, soe)) > + perror("PTP_SYS_OFFSET_EXTENDED"); > + else { > + printf("extended timestamp request returned %d samples\n", > + getextended); > + > + for (i = 0; i < getextended; i++) { > + printf("sample #%2d: system time before: %lld.%09u\n", > + i, soe->ts[i][0].sec, soe->ts[i][0].nsec); > + printf(" phc time: %lld.%09u\n", > + soe->ts[i][1].sec, soe->ts[i][1].nsec); > + printf(" system time after: %lld.%09u\n", > + soe->ts[i][2].sec, soe->ts[i][2].nsec); > + } > + } > + > + free(soe); > + } > + > close(fd); > return 0; > } > -- > 2.28.0 > > -- /Horatiu