Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp462599pxb; Mon, 16 Aug 2021 09:18:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdgMLvqpC5F9tPm547p6Q55aIlltUUFufRnrl8hHNLOq+hpJ2C8EXfl/wT/30Gxccf+Go4 X-Received: by 2002:a05:6e02:12a3:: with SMTP id f3mr8631330ilr.46.1629130738528; Mon, 16 Aug 2021 09:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629130738; cv=none; d=google.com; s=arc-20160816; b=nQMsNrjhiwHbPfc3rQM7mGlcxYgY/20blhrzLYdtb+VHvXAa+vwMEK8xwnyRQBtxuO dSfZZadpUNwD9vqyuQoP7/M+xG8ui4HcqzRaSgvL8u20ndOVE5lJycG3uJWn2G63haKZ U9T2bVOsUEhLCzsDqLqIGNoZic6WzQCiTV4aKGZUBrvfjTc/fvaqvykLe0px39ziAnyj oYGi1ubLmL+ozZGS+7Uivmd3aOYxf2Fa6H/tlOvXA52GPwt5LGEK2fAjwTWTHmTCv3Pb W6AFkwR3yJKLJ2nDuG4Z7rdBdaiWb3wuDlNCR7SMEIpHbnH+4XpxH2evG0dcLEjtRk3F r2BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=AXulC4UpOR3vQ8DV22W/BjxN1ZvD9ImcXjsR64hQGPY=; b=TIMmC3XaDI8rgIzHnWeFaXub35kzq9N+JFUPrQv0OVY7sxUV3wDjh7/TxKR4F1Ef5P AFytFz16qvX0Fj1NCGjHAwFkD9G062m6c2XuGbRIksj5W2wF+G4f0fLlBGcgTRmaRROz 93DeCKcF/knAU5qkXMvhpN0KylEilkXMQ6riwAMmM923Wps8qTv1LJ9YAAXAHyqL7WTK 0Nz7VGyZEvt42cTgdSt4ntaVZwjO04YQTPoOzUMLMKe93JH+wmdMPG4f77JPgYwiSGMe k5cJfb2406O3G4HnzuEeZY4laoON7CaXi8AxRrO9D8mVjQBJozGVOmXGuj7/Mgz6iYYz 5IOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h199si6317784iof.50.2021.08.16.09.18.45; Mon, 16 Aug 2021 09:18:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229986AbhHPQST (ORCPT + 99 others); Mon, 16 Aug 2021 12:18:19 -0400 Received: from mga09.intel.com ([134.134.136.24]:19482 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbhHPQSO (ORCPT ); Mon, 16 Aug 2021 12:18:14 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10078"; a="215889356" X-IronPort-AV: E=Sophos;i="5.84,326,1620716400"; d="scan'208";a="215889356" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Aug 2021 09:17:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,326,1620716400"; d="scan'208";a="487523947" Received: from amlin-018-053.igk.intel.com ([10.102.18.53]) by fmsmga008.fm.intel.com with ESMTP; 16 Aug 2021 09:17:39 -0700 From: Arkadiusz Kubalewski To: linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, kuba@kernel.org, richardcochran@gmail.com, shuah@kernel.org, arkadiusz.kubalewski@intel.com, arnd@arndb.de, nikolay@nvidia.com, cong.wang@bytedance.com, colin.king@canonical.com, gustavoars@kernel.org Subject: [RFC net-next 2/7] selftests/ptp: Add usage of PTP_DPLL_GETSTATE ioctl in testptp Date: Mon, 16 Aug 2021 18:07:12 +0200 Message-Id: <20210816160717.31285-3-arkadiusz.kubalewski@intel.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20210816160717.31285-1-arkadiusz.kubalewski@intel.com> References: <20210816160717.31285-1-arkadiusz.kubalewski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow get Digital Phase Locked Loop state of ptp enabled device through ptp related ioctl PTP_DPLL_GETSTATE. Signed-off-by: Arkadiusz Kubalewski --- tools/testing/selftests/ptp/testptp.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/ptp/testptp.c b/tools/testing/selftests/ptp/testptp.c index f7911aaeb007..67de96cf0962 100644 --- a/tools/testing/selftests/ptp/testptp.c +++ b/tools/testing/selftests/ptp/testptp.c @@ -141,6 +141,7 @@ 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" + " -u get list of available DPLLs and their state values" " -z test combinations of rising/falling external time stamp flags\n", progname); } @@ -156,6 +157,7 @@ int main(int argc, char *argv[]) struct timex tx; struct ptp_clock_time *pct; struct ptp_sys_offset *sysoff; + struct ptp_dpll_state *ds; char *progname; unsigned int i; @@ -177,6 +179,7 @@ int main(int argc, char *argv[]) int pps = -1; int seconds = 0; int settime = 0; + int dpll_state = 0; int64_t t1, t2, tp; int64_t interval, offset; @@ -186,7 +189,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:p:P:sSt:T:w:z"))) { + while (EOF != (c = getopt(argc, argv, "cd:e:f:ghH:i:k:lL:p:P:sSt:T:uw:z"))) { switch (c) { case 'c': capabilities = 1; @@ -242,6 +245,9 @@ int main(int argc, char *argv[]) settime = 3; seconds = atoi(optarg); break; + case 'u': + dpll_state = 1; + break; case 'w': pulsewidth = atoi(optarg); break; @@ -506,6 +512,25 @@ int main(int argc, char *argv[]) free(sysoff); } + if (dpll_state) { + ds = calloc(1, sizeof(*ds)); + if (!ds) { + perror("calloc"); + return -1; + } + + if (ioctl(fd, PTP_DPLL_GETSTATE, ds)) + perror("PTP_DPLL_GETSTATE"); + else + puts("get dpll state request okay"); + + printf("dpll state:\n"); + for (i = 0; i < ds->dpll_num; i++) + printf("dpll id:%i state:%u\n", i, ds->state[i]); + + free(ds); + } + close(fd); return 0; } -- 2.24.0