From: Yangbo Lu <yangbo.lu@nxp.com> Date: 2021-06-15 09:36:38
Current PTP driver exposes one PTP device to user which binds network
interface/interfaces to provide timestamping. Actually we have a way
utilizing timecounter/cyclecounter to virtualize any number of PTP
clocks based on a same free running physical clock for using.
The purpose of having multiple PTP virtual clocks is for user space
to directly/easily use them for multiple domains synchronization.
user
space: ^ ^
| SO_TIMESTAMPING new flag: | Packets with
| SOF_TIMESTAMPING_BIND_PHC | TX/RX HW timestamps
v v
+--------------------------------------------+
sock: | sock (new member sk_bind_phc) |
+--------------------------------------------+
^ ^
| ethtool_op_get_phc_vclocks | Convert HW timestamps
| | to sk_bind_phc
v v
+--------------+--------------+--------------+
vclock: | ptp1 | ptp2 | ptpN |
+--------------+--------------+--------------+
pclock: | ptp0 free running |
+--------------------------------------------+
The block diagram may explain how it works. Besides the PTP virtual
clocks, the packet HW timestamp converting to the bound PHC is also
done in sock driver. For user space, PTP virtual clocks can be
created via sysfs, and extended SO_TIMESTAMPING API (new flag
SOF_TIMESTAMPING_BIND_PHC) can be used to bind one PTP virtual clock
for timestamping.
The test tool timestamping.c (together with linuxptp phc_ctl tool) can
be used to verify:
# echo 4 > /sys/class/ptp/ptp0/n_vclocks
[ 129.399472] ptp ptp0: new virtual clock ptp2
[ 129.404234] ptp ptp0: new virtual clock ptp3
[ 129.409532] ptp ptp0: new virtual clock ptp4
[ 129.413942] ptp ptp0: new virtual clock ptp5
[ 129.418257] ptp ptp0: guarantee physical clock free running
#
# phc_ctl /dev/ptp2 set 10000
# phc_ctl /dev/ptp3 set 20000
#
# timestamping eno0 2 SOF_TIMESTAMPING_TX_HARDWARE SOF_TIMESTAMPING_RAW_HARDWARE SOF_TIMESTAMPING_BIND_PHC
# timestamping eno0 2 SOF_TIMESTAMPING_RX_HARDWARE SOF_TIMESTAMPING_RAW_HARDWARE SOF_TIMESTAMPING_BIND_PHC
# timestamping eno0 3 SOF_TIMESTAMPING_TX_HARDWARE SOF_TIMESTAMPING_RAW_HARDWARE SOF_TIMESTAMPING_BIND_PHC
# timestamping eno0 3 SOF_TIMESTAMPING_RX_HARDWARE SOF_TIMESTAMPING_RAW_HARDWARE SOF_TIMESTAMPING_BIND_PHC
Changes for v2:
- Converted to num_vclocks for creating virtual clocks.
- Guranteed physical clock free running when using virtual
clocks.
- Fixed build warning.
- Updated copyright.
Changes for v3:
- Supported PTP virtual clock in default in PTP driver.
- Protected concurrency of ptp->num_vclocks accessing.
- Supported PHC vclocks query via ethtool.
- Extended SO_TIMESTAMPING API for PHC binding.
- Converted HW timestamps to PHC bound, instead of previous
binding domain value to PHC idea.
- Other minor fixes.
Yangbo Lu (10):
ptp: add ptp virtual clock driver framework
ptp: support ptp physical/virtual clocks conversion
ptp: track available ptp vclocks information
ptp: add kernel API ptp_get_vclocks_index()
ethtool: add a new command for getting PHC virtual clocks
ptp: add kernel API ptp_convert_timestamp()
net: sock: extend SO_TIMESTAMPING for PHC binding
net: socket: support hardware timestamp conversion to PHC bound
selftests/net: timestamping: support binding PHC
MAINTAINERS: add entry for PTP virtual clock driver
Documentation/ABI/testing/sysfs-ptp | 13 ++
MAINTAINERS | 7 +
drivers/ptp/Makefile | 2 +-
drivers/ptp/ptp_clock.c | 27 ++-
drivers/ptp/ptp_private.h | 34 ++++
drivers/ptp/ptp_sysfs.c | 95 +++++++++
drivers/ptp/ptp_vclock.c | 212 +++++++++++++++++++++
include/linux/ethtool.h | 2 +
include/linux/ptp_clock_kernel.h | 29 ++-
include/net/sock.h | 8 +-
include/uapi/linux/ethtool.h | 14 ++
include/uapi/linux/ethtool_netlink.h | 15 ++
include/uapi/linux/net_tstamp.h | 17 +-
include/uapi/linux/ptp_clock.h | 5 +
net/core/sock.c | 65 ++++++-
net/ethtool/Makefile | 2 +-
net/ethtool/common.c | 24 +++
net/ethtool/common.h | 2 +
net/ethtool/ioctl.c | 27 +++
net/ethtool/netlink.c | 10 +
net/ethtool/netlink.h | 2 +
net/ethtool/phc_vclocks.c | 86 +++++++++
net/mptcp/sockopt.c | 10 +-
net/socket.c | 19 +-
tools/testing/selftests/net/timestamping.c | 62 ++++--
25 files changed, 750 insertions(+), 39 deletions(-)
create mode 100644 drivers/ptp/ptp_vclock.c
create mode 100644 net/ethtool/phc_vclocks.c
base-commit: 89212e160b81e778f829b89743570665810e3b13
--
2.25.1
@@ -0,0 +1,154 @@+// SPDX-License-Identifier: GPL-2.0-or-later+/*+*PTPvirtualclockdriver+*+*Copyright2021NXP+*/+#include<linux/slab.h>+#include"ptp_private.h"++#define PTP_VCLOCK_CC_MULT (1 << 31)+#define PTP_VCLOCK_CC_SHIFT 31+#define PTP_VCLOCK_CC_MULT_NUM (1 << 9)+#define PTP_VCLOCK_CC_MULT_DEM 15625ULL+#define PTP_VCLOCK_CC_REFRESH_INTERVAL (HZ * 2)++staticintptp_vclock_adjfine(structptp_clock_info*ptp,longscaled_ppm)+{+structptp_vclock*vclock=info_to_vclock(ptp);+unsignedlongflags;+s64adj;++adj=(s64)scaled_ppm*PTP_VCLOCK_CC_MULT_NUM;+adj=div_s64(adj,PTP_VCLOCK_CC_MULT_DEM);++spin_lock_irqsave(&vclock->lock,flags);+timecounter_read(&vclock->tc);+vclock->cc.mult=PTP_VCLOCK_CC_MULT+adj;+spin_unlock_irqrestore(&vclock->lock,flags);++return0;+}++staticintptp_vclock_adjtime(structptp_clock_info*ptp,s64delta)+{+structptp_vclock*vclock=info_to_vclock(ptp);+unsignedlongflags;++spin_lock_irqsave(&vclock->lock,flags);+timecounter_adjtime(&vclock->tc,delta);+spin_unlock_irqrestore(&vclock->lock,flags);++return0;+}++staticintptp_vclock_gettime(structptp_clock_info*ptp,+structtimespec64*ts)+{+structptp_vclock*vclock=info_to_vclock(ptp);+unsignedlongflags;+u64ns;++spin_lock_irqsave(&vclock->lock,flags);+ns=timecounter_read(&vclock->tc);+spin_unlock_irqrestore(&vclock->lock,flags);+*ts=ns_to_timespec64(ns);++return0;+}++staticintptp_vclock_settime(structptp_clock_info*ptp,+conststructtimespec64*ts)+{+structptp_vclock*vclock=info_to_vclock(ptp);+u64ns=timespec64_to_ns(ts);+unsignedlongflags;++spin_lock_irqsave(&vclock->lock,flags);+timecounter_init(&vclock->tc,&vclock->cc,ns);+spin_unlock_irqrestore(&vclock->lock,flags);++return0;+}++staticconststructptp_clock_infoptp_vclock_info={+.owner=THIS_MODULE,+.name="ptp virtual clock",+/* The maximum ppb value that long scaled_ppm can support */+.max_adj=32767999,+.adjfine=ptp_vclock_adjfine,+.adjtime=ptp_vclock_adjtime,+.gettime64=ptp_vclock_gettime,+.settime64=ptp_vclock_settime,+};++staticvoidptp_vclock_refresh(structwork_struct*work)+{+structdelayed_work*dw=to_delayed_work(work);+structptp_vclock*vclock=dw_to_vclock(dw);+structtimespec64ts;++ptp_vclock_gettime(&vclock->info,&ts);+schedule_delayed_work(&vclock->refresh_work,+PTP_VCLOCK_CC_REFRESH_INTERVAL);+}++staticu64ptp_vclock_read(conststructcyclecounter*cc)+{+structptp_vclock*vclock=cc_to_vclock(cc);+structptp_clock*ptp=vclock->pclock;+structtimespec64ts={};++if(ptp->info->gettimex64)+ptp->info->gettimex64(ptp->info,&ts,NULL);+else+ptp->info->gettime64(ptp->info,&ts);++returntimespec64_to_ns(&ts);+}++staticconststructcyclecounterptp_vclock_cc={+.read=ptp_vclock_read,+.mask=CYCLECOUNTER_MASK(32),+.mult=PTP_VCLOCK_CC_MULT,+.shift=PTP_VCLOCK_CC_SHIFT,+};++structptp_vclock*ptp_vclock_register(structptp_clock*pclock)+{+structptp_vclock*vclock;++vclock=kzalloc(sizeof(*vclock),GFP_KERNEL);+if(!vclock)+returnNULL;++vclock->pclock=pclock;+vclock->info=ptp_vclock_info;+vclock->cc=ptp_vclock_cc;++snprintf(vclock->info.name,PTP_CLOCK_NAME_LEN,"ptp%d_virt",+pclock->index);++spin_lock_init(&vclock->lock);++vclock->clock=ptp_clock_register(&vclock->info,&pclock->dev);+if(IS_ERR_OR_NULL(vclock->clock)){+kfree(vclock);+returnNULL;+}++timecounter_init(&vclock->tc,&vclock->cc,0);++INIT_DELAYED_WORK(&vclock->refresh_work,ptp_vclock_refresh);+schedule_delayed_work(&vclock->refresh_work,+PTP_VCLOCK_CC_REFRESH_INTERVAL);++returnvclock;+}++voidptp_vclock_unregister(structptp_vclock*vclock)+{+cancel_delayed_work_sync(&vclock->refresh_work);+ptp_clock_unregister(vclock->clock);+kfree(vclock);+}
From: Yangbo Lu <yangbo.lu@nxp.com> Date: 2021-06-15 09:36:45
Support ptp physical/virtual clocks conversion via sysfs.
There will be a new attribute n_vclocks under ptp physical
clock sysfs.
- In default, the value is 0 meaning only ptp physical clock
is in use.
- Setting the value can create corresponding number of ptp
virtual clocks to use. But current physical clock is guaranteed
to stay free running.
- Setting the value back to 0 can delete virtual clocks and back
use physical clock again.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
Changes for v2:
- Split from v1 patch #2.
- Converted to num_vclocks for creating virtual clocks.
- Guranteed physical clock free running when using virtual
clocks.
- Fixed build warning.
- Updated copyright.
Changes for v3:
- Protected concurrency of ptp->num_vclocks accessing.
---
Documentation/ABI/testing/sysfs-ptp | 13 +++++
drivers/ptp/ptp_clock.c | 22 +++++++
drivers/ptp/ptp_private.h | 15 +++++
drivers/ptp/ptp_sysfs.c | 89 +++++++++++++++++++++++++++++
include/uapi/linux/ptp_clock.h | 5 ++
5 files changed, 144 insertions(+)
@@ -61,6 +61,19 @@ Description: This file contains the number of programmable pins offered by the PTP hardware clock.+What: /sys/class/ptp/ptpN/n_vclocks+Date: May 2021+Contact: Yangbo Lu <yangbo.lu@nxp.com>+Description:+ This file contains the ptp virtual clocks number in use,+ based on current ptp physical clock. In default, the+ value is 0 meaning only ptp physical clock is in use.+ Setting the value can create corresponding number of ptp+ virtual clocks to use. But current ptp physical clock is+ guaranteed to stay free running. Setting the value back+ to 0 can delete ptp virtual clocks and back use ptp+ physical clock again.+ What: /sys/class/ptp/ptpN/pins Date: March 2014 Contact: Richard Cochran <richardcochran@gmail.com>
@@ -148,6 +149,90 @@ static ssize_t pps_enable_store(struct device *dev,}staticDEVICE_ATTR(pps_enable,0220,NULL,pps_enable_store);+staticintunregister_vclock(structdevice*dev,void*data)+{+structptp_clock*ptp=dev_get_drvdata(dev);+structptp_clock_info*info=ptp->info;+structptp_vclock*vclock;+u8*num=data;++vclock=info_to_vclock(info);+dev_info(dev->parent,"delete virtual clock ptp%d\n",+vclock->clock->index);++ptp_vclock_unregister(vclock);+(*num)--;++/* For break. Not error. */+if(*num==0)+return-EINVAL;++return0;+}++staticssize_tn_vclocks_show(structdevice*dev,+structdevice_attribute*attr,char*page)+{+structptp_clock*ptp=dev_get_drvdata(dev);++returnsnprintf(page,PAGE_SIZE-1,"%d\n",ptp->n_vclocks);+}++staticssize_tn_vclocks_store(structdevice*dev,+structdevice_attribute*attr,+constchar*buf,size_tcount)+{+structptp_clock*ptp=dev_get_drvdata(dev);+structptp_vclock*vclock;+interr=-EINVAL;+u8num,i;++if(kstrtou8(buf,0,&num))+gotoout;++if(num>PTP_MAX_VCLOCKS){+dev_err(dev,"max value is %d\n",PTP_MAX_VCLOCKS);+gotoout;+}++if(mutex_lock_interruptible(&ptp->n_vclocks_mux))+return-ERESTARTSYS;++/* Need to create more vclocks */+if(num>ptp->n_vclocks){+for(i=0;i<num-ptp->n_vclocks;i++){+vclock=ptp_vclock_register(ptp);+if(!vclock){+mutex_unlock(&ptp->n_vclocks_mux);+gotoout;+}++dev_info(dev,"new virtual clock ptp%d\n",+vclock->clock->index);+}+}++/* Need to delete vclocks */+if(num<ptp->n_vclocks){+i=ptp->n_vclocks-num;+device_for_each_child_reverse(dev,&i,+unregister_vclock);+}++if(num==0)+dev_info(dev,"only physical clock in use now\n");+else+dev_info(dev,"guarantee physical clock free running\n");++ptp->n_vclocks=num;+mutex_unlock(&ptp->n_vclocks_mux);++returncount;+out:+returnerr;+}+staticDEVICE_ATTR_RW(n_vclocks);+staticstructattribute*ptp_attrs[]={&dev_attr_clock_name.attr,
From: Yangbo Lu <yangbo.lu@nxp.com> Date: 2021-06-15 09:36:49
Track available ptp vclocks information. Record index values
of available ptp vclocks during registering and unregistering.
This is preparation for supporting ptp vclocks info query
through ethtool.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
Change for v3:
- Added this patch.
---
drivers/ptp/ptp_clock.c | 2 ++
drivers/ptp/ptp_private.h | 1 +
drivers/ptp/ptp_sysfs.c | 6 ++++++
3 files changed, 9 insertions(+)
From: Yangbo Lu <yangbo.lu@nxp.com> Date: 2021-06-15 09:36:53
Add kernel API ptp_get_vclocks_index() to get all ptp
vclocks index on pclock.
This is preparation for supporting ptp vclocks info query
through ethtool.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
Changes for v3:
- Added this patch.
---
drivers/ptp/ptp_clock.c | 3 ++-
drivers/ptp/ptp_private.h | 2 ++
drivers/ptp/ptp_vclock.c | 24 ++++++++++++++++++++++++
include/linux/ptp_clock_kernel.h | 12 ++++++++++++
4 files changed, 40 insertions(+), 1 deletion(-)
@@ -86,6 +86,8 @@ struct netlink_ext_ack;/* Some generic methods drivers may use in their ethtool_ops */u32ethtool_op_get_link(structnet_device*dev);intethtool_op_get_ts_info(structnet_device*dev,structethtool_ts_info*eti);+intethtool_op_get_phc_vclocks(structnet_device*dev,+structethtool_phc_vclocks*phc_vclocks);/* Link extended state and substate. */
From: Yangbo Lu <yangbo.lu@nxp.com> Date: 2021-06-15 09:36:57
Add kernel API ptp_convert_timestamp() to convert raw hardware timestamp
to a specified ptp vclock time.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
Changes for v2:
- Split from v1 patch #1 and #2.
- Fixed build warning.
Changes for v3:
- Converted HW timestamps to PHC bound, instead of previous
binding domain value to PHC idea.
---
drivers/ptp/ptp_vclock.c | 34 ++++++++++++++++++++++++++++++++
include/linux/ptp_clock_kernel.h | 13 ++++++++++++
2 files changed, 47 insertions(+)
@@ -176,3 +176,37 @@ int ptp_get_vclocks_index(int pclock_index, int *vclock_index)returnnum;}EXPORT_SYMBOL(ptp_get_vclocks_index);++voidptp_convert_timestamp(structskb_shared_hwtstamps*hwtstamps,+intvclock_index)+{+charname[PTP_CLOCK_NAME_LEN]="";+structptp_vclock*vclock;+structptp_clock*ptp;+unsignedlongflags;+structdevice*dev;+u64ns;++snprintf(name,PTP_CLOCK_NAME_LEN,"ptp%d",vclock_index);+dev=class_find_device_by_name(ptp_class,name);+if(!dev)+return;++ptp=dev_get_drvdata(dev);+if(!ptp->vclock_flag){+put_device(dev);+return;+}++vclock=info_to_vclock(ptp->info);++ns=ktime_to_ns(hwtstamps->hwtstamp);++spin_lock_irqsave(&vclock->lock,flags);+ns=timecounter_cyc2time(&vclock->tc,ns);+spin_unlock_irqrestore(&vclock->lock,flags);++put_device(dev);+hwtstamps->hwtstamp=ns_to_ktime(ns);+}+EXPORT_SYMBOL(ptp_convert_timestamp);
From: Yangbo Lu <yangbo.lu@nxp.com> Date: 2021-06-15 09:37:02
This patch is to support hardware timestamp conversion to
PHC bound. This applies to both RX and TX since their skb
handling (for TX, it's skb clone in error queue) all goes
through __sock_recv_timestamp.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
Changes for v3:
- Added this patch.
---
net/socket.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
@@ -43,11 +43,19 @@# define SO_TIMESTAMPNS 35#endif+#ifndef SOF_TIMESTAMPING_BIND_PHC+#define SOF_TIMESTAMPING_BIND_PHC (1<<15)+structso_timestamping{+intflags;+intbind_phc;+};+#endif+staticvoidusage(constchar*error){if(error)printf("invalid option: %s\n",error);-printf("timestamping interface option*\n\n"+printf("timestamping <interface> [bind_phc_index] [option]*\n\n""Options:\n"" IP_MULTICAST_LOOP - looping outgoing multicasts\n"" SO_TIMESTAMP - normal software time stamping, ms resolution\n"
@@ -58,6 +66,7 @@ static void usage(const char *error)" SOF_TIMESTAMPING_RX_SOFTWARE - software fallback for incoming packets\n"" SOF_TIMESTAMPING_SOFTWARE - request reporting of software time stamps\n"" SOF_TIMESTAMPING_RAW_HARDWARE - request reporting of raw HW time stamps\n"+" SOF_TIMESTAMPING_BIND_PHC - request to bind a PHC of PTP vclock\n"" SIOCGSTAMP - check last socket time stamp\n"" SIOCGSTAMPNS - more accurate socket time stamp\n"" PTPV2 - use PTPv2 messages\n");
@@ -311,7 +320,6 @@ static void recvpacket(int sock, int recvmsg_flags,intmain(intargc,char**argv){-intso_timestamping_flags=0;intso_timestamp=0;intso_timestampns=0;intsiocgstamp=0;
@@ -325,6 +333,8 @@ int main(int argc, char **argv)structifreqdevice;structifreqhwtstamp;structhwtstamp_confighwconfig,hwconfig_requested;+structso_timestampingso_timestamping_get={0,-1};+structso_timestampingso_timestamping={0,-1};structsockaddr_inaddr;structip_mreqimr;structin_addriaddr;
@@ -342,7 +352,12 @@ int main(int argc, char **argv)exit(1);}-for(i=2;i<argc;i++){+if(argc>=3&&sscanf(argv[2],"%d",&so_timestamping.bind_phc)==1)+val=3;+else+val=2;++for(i=val;i<argc;i++){if(!strcasecmp(argv[i],"SO_TIMESTAMP"))so_timestamp=1;elseif(!strcasecmp(argv[i],"SO_TIMESTAMPNS"))
@@ -356,17 +371,19 @@ int main(int argc, char **argv)elseif(!strcasecmp(argv[i],"PTPV2"))ptpv2=1;elseif(!strcasecmp(argv[i],"SOF_TIMESTAMPING_TX_HARDWARE"))-so_timestamping_flags|=SOF_TIMESTAMPING_TX_HARDWARE;+so_timestamping.flags|=SOF_TIMESTAMPING_TX_HARDWARE;elseif(!strcasecmp(argv[i],"SOF_TIMESTAMPING_TX_SOFTWARE"))-so_timestamping_flags|=SOF_TIMESTAMPING_TX_SOFTWARE;+so_timestamping.flags|=SOF_TIMESTAMPING_TX_SOFTWARE;elseif(!strcasecmp(argv[i],"SOF_TIMESTAMPING_RX_HARDWARE"))-so_timestamping_flags|=SOF_TIMESTAMPING_RX_HARDWARE;+so_timestamping.flags|=SOF_TIMESTAMPING_RX_HARDWARE;elseif(!strcasecmp(argv[i],"SOF_TIMESTAMPING_RX_SOFTWARE"))-so_timestamping_flags|=SOF_TIMESTAMPING_RX_SOFTWARE;+so_timestamping.flags|=SOF_TIMESTAMPING_RX_SOFTWARE;elseif(!strcasecmp(argv[i],"SOF_TIMESTAMPING_SOFTWARE"))-so_timestamping_flags|=SOF_TIMESTAMPING_SOFTWARE;+so_timestamping.flags|=SOF_TIMESTAMPING_SOFTWARE;elseif(!strcasecmp(argv[i],"SOF_TIMESTAMPING_RAW_HARDWARE"))-so_timestamping_flags|=SOF_TIMESTAMPING_RAW_HARDWARE;+so_timestamping.flags|=SOF_TIMESTAMPING_RAW_HARDWARE;+elseif(!strcasecmp(argv[i],"SOF_TIMESTAMPING_BIND_PHC"))+so_timestamping.flags|=SOF_TIMESTAMPING_BIND_PHC;elseusage(argv[i]);}
@@ -385,10 +402,10 @@ int main(int argc, char **argv)hwtstamp.ifr_data=(void*)&hwconfig;memset(&hwconfig,0,sizeof(hwconfig));hwconfig.tx_type=-(so_timestamping_flags&SOF_TIMESTAMPING_TX_HARDWARE)?+(so_timestamping.flags&SOF_TIMESTAMPING_TX_HARDWARE)?HWTSTAMP_TX_ON:HWTSTAMP_TX_OFF;hwconfig.rx_filter=-(so_timestamping_flags&SOF_TIMESTAMPING_RX_HARDWARE)?+(so_timestamping.flags&SOF_TIMESTAMPING_RX_HARDWARE)?ptpv2?HWTSTAMP_FILTER_PTP_V2_L4_SYNC:HWTSTAMP_FILTER_PTP_V1_L4_SYNC:HWTSTAMP_FILTER_NONE;hwconfig_requested=hwconfig;
@@ -413,6 +430,9 @@ int main(int argc, char **argv)sizeof(structsockaddr_in))<0)bail("bind");+if(setsockopt(sock,SOL_SOCKET,SO_BINDTODEVICE,interface,if_len))+bail("bind device");+/* set multicast group for outgoing packets */inet_aton("224.0.1.130",&iaddr);/* alternate PTP domain 1 */addr.sin_addr=iaddr;
@@ -444,10 +464,10 @@ int main(int argc, char **argv)&enabled,sizeof(enabled))<0)bail("setsockopt SO_TIMESTAMPNS");-if(so_timestamping_flags&&+if(so_timestamping.flags&&setsockopt(sock,SOL_SOCKET,SO_TIMESTAMPING,-&so_timestamping_flags,-sizeof(so_timestamping_flags))<0)+&so_timestamping,+sizeof(so_timestamping))<0)bail("setsockopt SO_TIMESTAMPING");/* request IP_PKTINFO for debugging purposes */
@@ -468,14 +488,18 @@ int main(int argc, char **argv)elseprintf("SO_TIMESTAMPNS %d\n",val);-if(getsockopt(sock,SOL_SOCKET,SO_TIMESTAMPING,&val,&len)<0){+len=sizeof(so_timestamping_get);+if(getsockopt(sock,SOL_SOCKET,SO_TIMESTAMPING,&so_timestamping_get,+&len)<0){printf("%s: %s\n","getsockopt SO_TIMESTAMPING",strerror(errno));}else{-printf("SO_TIMESTAMPING %d\n",val);-if(val!=so_timestamping_flags)-printf(" not the expected value %d\n",-so_timestamping_flags);+printf("SO_TIMESTAMPING flags %d, bind phc %d\n",+so_timestamping_get.flags,so_timestamping_get.bind_phc);+if(so_timestamping_get.flags!=so_timestamping.flags||+so_timestamping_get.bind_phc!=so_timestamping.bind_phc)+printf(" not expected, flags %d, bind phc %d\n",+so_timestamping.flags,so_timestamping.bind_phc);}/* send packets forever every five seconds */
From: Yangbo Lu <yangbo.lu@nxp.com> Date: 2021-06-15 09:38:50
Since PTP virtual clock support is added, there can be
several PTP virtual clocks based on one PTP physical
clock for timestamping.
This patch is to extend SO_TIMESTAMPING API to support
PHC (PTP Hardware Clock) binding by adding a new flag
SOF_TIMESTAMPING_BIND_PHC. When PTP virtual clocks are
in use, user space can configure to bind one for
timestamping, but PTP physical clock is not supported
and not needed to bind.
This patch is preparation for timestamp conversion from
raw timestamp to a specific PTP virtual clock time in
core net.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
Changes for v3:
- Added this patch.
---
include/net/sock.h | 8 +++-
include/uapi/linux/net_tstamp.h | 17 ++++++++-
net/core/sock.c | 65 +++++++++++++++++++++++++++++++--
net/ethtool/common.c | 1 +
net/mptcp/sockopt.c | 10 +++--
5 files changed, 91 insertions(+), 10 deletions(-)
@@ -13,7 +13,7 @@#include<linux/types.h>#include<linux/socket.h> /* for SO_TIMESTAMPING */-/* SO_TIMESTAMPING gets an integer bit field comprised of these values */+/* SO_TIMESTAMPING flags */enum{SOF_TIMESTAMPING_TX_HARDWARE=(1<<0),SOF_TIMESTAMPING_TX_SOFTWARE=(1<<1),
@@ -794,8 +796,53 @@ void sock_set_timestamp(struct sock *sk, int optname, bool valbool)}}-intsock_set_timestamping(structsock*sk,intoptname,intval)+staticintsock_timestamping_bind_phc(structsock*sk,intphc_index){+structethtool_phc_vclocksphc_vclocks={};+structnet*net=sock_net(sk);+structnet_device*dev=NULL;+boolmatch=false;+inti;++if(sk->sk_bound_dev_if)+dev=dev_get_by_index(net,sk->sk_bound_dev_if);++if(!dev){+pr_err("%s: sock not bind to device\n",__func__);+return-EOPNOTSUPP;+}++ethtool_op_get_phc_vclocks(dev,&phc_vclocks);++for(i=0;i<phc_vclocks.num;i++){+if(phc_vclocks.index[i]==phc_index){+match=true;+break;+}+}++if(!match)+return-EINVAL;++sk->sk_bind_phc=phc_index;++return0;+}++intsock_set_timestamping(structsock*sk,intoptname,intval,+sockptr_toptval,unsignedintoptlen)+{+structso_timestampingtimestamping;+intret;++if(optlen==sizeof(timestamping)){+if(copy_from_sockptr(×tamping,optval,+sizeof(timestamping)))+return-EFAULT;++val=timestamping.flags;+}+if(val&~SOF_TIMESTAMPING_MASK)return-EINVAL;
@@ -816,6 +863,15 @@ int sock_set_timestamping(struct sock *sk, int optname, int val)!(val&SOF_TIMESTAMPING_OPT_TSONLY))return-EINVAL;+if(optlen==sizeof(timestamping)&&+val&SOF_TIMESTAMPING_BIND_PHC){+ret=sock_timestamping_bind_phc(sk,timestamping.bind_phc);+if(ret)+returnret;+}else{+sk->sk_bind_phc=-1;+}+sk->sk_tsflags=val;sock_valbool_flag(sk,SOCK_TSTAMP_NEW,optname==SO_TIMESTAMPING_NEW);
@@ -1057,7 +1113,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,caseSO_TIMESTAMPING_NEW:caseSO_TIMESTAMPING_OLD:-ret=sock_set_timestamping(sk,optname,val);+ret=sock_set_timestamping(sk,optname,val,optval,optlen);break;caseSO_RCVLOWAT:
@@ -1332,6 +1388,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,struct__kernel_old_timevaltm;struct__kernel_sock_timevalstm;structsock_txtimetxtime;+structso_timestampingtimestamping;}v;intlv=sizeof(int);
@@ -1435,7 +1492,9 @@ int sock_getsockopt(struct socket *sock, int level, int optname,break;caseSO_TIMESTAMPING_OLD:-v.val=sk->sk_tsflags;+lv=sizeof(v.timestamping);+v.timestamping.flags=sk->sk_tsflags;+v.timestamping.bind_phc=sk->sk_bind_phc;break;caseSO_RCVTIMEO_OLD:
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-06-15 19:49:18
On Tue, 15 Jun 2021 17:45:12 +0800 Yangbo Lu wrote:
Add an interface for getting PHC (PTP Hardware Clock)
virtual clocks, which are based on PHC physical clock
providing hardware timestamp to network packets.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
From: Mat Martineau <hidden> Date: 2021-06-16 01:00:41
On Tue, 15 Jun 2021, Yangbo Lu wrote:
quoted hunk
Since PTP virtual clock support is added, there can be
several PTP virtual clocks based on one PTP physical
clock for timestamping.
This patch is to extend SO_TIMESTAMPING API to support
PHC (PTP Hardware Clock) binding by adding a new flag
SOF_TIMESTAMPING_BIND_PHC. When PTP virtual clocks are
in use, user space can configure to bind one for
timestamping, but PTP physical clock is not supported
and not needed to bind.
This patch is preparation for timestamp conversion from
raw timestamp to a specific PTP virtual clock time in
core net.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
Changes for v3:
- Added this patch.
---
include/net/sock.h | 8 +++-
include/uapi/linux/net_tstamp.h | 17 ++++++++-
net/core/sock.c | 65 +++++++++++++++++++++++++++++++--
net/ethtool/common.c | 1 +
net/mptcp/sockopt.c | 10 +++--
5 files changed, 91 insertions(+), 10 deletions(-)
@@ -1057,7 +1113,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
case SO_TIMESTAMPING_NEW:
case SO_TIMESTAMPING_OLD:
- ret = sock_set_timestamping(sk, optname, val);
+ ret = sock_set_timestamping(sk, optname, val, optval, optlen);
break;
case SO_RCVLOWAT:
@@ -1332,6 +1388,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
mptcp_sol_socket_sync_intval(msk, SO_INCOMING_CPU, val);
}
-static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optname, int val)
+static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk,
+ int optname, int val,
+ sockptr_t optval,
+ unsigned int optlen)
{
sockptr_t optval = KERNEL_SOCKPTR(&val);
struct mptcp_subflow_context *subflow;
@@ -166,7 +169,7 @@ static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnam
break;
case SO_TIMESTAMPING_NEW:
case SO_TIMESTAMPING_OLD:
- sock_set_timestamping(sk, optname, val);
+ sock_set_timestamping(sk, optname, val, optval, optlen);
This is inside a loop, so in cases where optlen == sizeof(struct
so_timestamping) this will end up re-copying the structure from userspace
one extra time for each MPTCP subflow: once for the MPTCP socket, plus one
time for each of the TCP subflows that are grouped under this MPTCP
connection.
Given that the extra copies only happen when using the extended bind_phc
option, it's not a huge cost. But sock_set_timestamping() was written to
avoid the extra copies for 'int' sized options, and if that was worth the
effort then the larger so_timestamping structure could be copied (once)
before the sock_set_timestamping() call and passed in.
quoted hunk
break;
}
@@ -207,7 +210,8 @@ static int mptcp_setsockopt_sol_socket_int(struct mptcp_sock *msk, int optname,
case SO_TIMESTAMPNS_NEW:
case SO_TIMESTAMPING_OLD:
case SO_TIMESTAMPING_NEW:
- return mptcp_setsockopt_sol_socket_tstamp(msk, optname, val);
+ return mptcp_setsockopt_sol_socket_tstamp(msk, optname, val,
+ optval, optlen);
Rather than modifying mptcp_setsockopt_sol_socket_int(), I suggest adding
a mptcp_setsockopt_sol_socket_timestamping() helper function that can
handle the special copying for so_timestamping.
From: kernel test robot <hidden> Date: 2021-06-16 10:28:13
Hi Yangbo,
I love your patch! Yet something to improve:
[auto build test ERROR on 89212e160b81e778f829b89743570665810e3b13]
url: https://github.com/0day-ci/linux/commits/Yangbo-Lu/ptp-support-virtual-clocks-and-timestamping/20210616-141518
base: 89212e160b81e778f829b89743570665810e3b13
config: um-x86_64_defconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/f03864a45f4fe97414824545398c837eead55409
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yangbo-Lu/ptp-support-virtual-clocks-and-timestamping/20210616-141518
git checkout f03864a45f4fe97414824545398c837eead55409
# save the attached .config to linux build tree
make W=1 ARCH=um SUBARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <redacted>
All errors (new ones prefixed by >>):
net/mptcp/sockopt.c: In function 'mptcp_setsockopt_sol_socket_tstamp':
quoted
net/mptcp/sockopt.c:148:12: error: 'optval' redeclared as different kind of symbol
From: kernel test robot <hidden> Date: 2021-06-16 10:40:28
Hi Yangbo,
I love your patch! Yet something to improve:
[auto build test ERROR on 89212e160b81e778f829b89743570665810e3b13]
url: https://github.com/0day-ci/linux/commits/Yangbo-Lu/ptp-support-virtual-clocks-and-timestamping/20210616-141518
base: 89212e160b81e778f829b89743570665810e3b13
config: arm-randconfig-r023-20210615 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/f03864a45f4fe97414824545398c837eead55409
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yangbo-Lu/ptp-support-virtual-clocks-and-timestamping/20210616-141518
git checkout f03864a45f4fe97414824545398c837eead55409
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <redacted>
All errors (new ones prefixed by >>):
net/mptcp/sockopt.c: In function 'mptcp_setsockopt_sol_socket_tstamp':
quoted
net/mptcp/sockopt.c:148:12: error: 'optval' redeclared as different kind of symbol
the similarity of naming is confusing for these two. They are only
used in the .adjfine method. How about this?
PTP_VCLOCK_FADJ_NUMERATOR, or even PTP_VCLOCK_FADJ_SHIFT (see below)
PTP_VCLOCK_FADJ_DENOMINATOR
+#define PTP_VCLOCK_CC_REFRESH_INTERVAL (HZ * 2)
Consider dropping CC from the name.
PTP_VCLOCK_REFRESH_INTERVAL sounds good to me.
+static int ptp_vclock_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
+{
+ struct ptp_vclock *vclock = info_to_vclock(ptp);
+ unsigned long flags;
+ s64 adj;
+
+ adj = (s64)scaled_ppm * PTP_VCLOCK_CC_MULT_NUM;
Rather than
scaled_ppm * (1 << 9)
I suggest
scaled_ppm << 9
instead. I suppose a good compiler would replace the multiplication
with a bit shift, but it never hurts to spell it out.
@@ -61,6 +61,19 @@ Description: This file contains the number of programmable pins offered by the PTP hardware clock.+What: /sys/class/ptp/ptpN/n_vclocks+Date: May 2021+Contact: Yangbo Lu <yangbo.lu@nxp.com>+Description:+ This file contains the ptp virtual clocks number in use,+ based on current ptp physical clock. In default, the+ value is 0 meaning only ptp physical clock is in use.+ Setting the value can create corresponding number of ptp+ virtual clocks to use. But current ptp physical clock is+ guaranteed to stay free running. Setting the value back+ to 0 can delete ptp virtual clocks and back use ptp+ physical clock again.
The native speaker in me suggests:
This file contains the number of virtual PTP clocks in
use. By default, the value is 0 meaning that only the
physical clock is in use. Setting the value creates
the corresponding number of virtual clocks and causes
the physical clock to become free running. Setting the
value back to 0 deletes the virtual clocks and
switches the physical clock back to normal, adjustable
operation.
Thanks,
Richard
This is good: ^^^^^^^^^^^^^^^^^^^^^^^^^
You can drop this part: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
So, please rename ptp_guaranteed_pclock() to ptp_vclock_in_use();
-----Original Message-----
From: Jakub Kicinski <kuba@kernel.org>
Sent: 2021年6月16日 3:49
To: Y.b. Lu <yangbo.lu@nxp.com>
Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-kselftest@vger.kernel.org; mptcp@lists.linux.dev; Richard Cochran
[off-list ref]; David S . Miller [off-list ref]; Mat
Martineau [off-list ref]; Matthieu Baerts
[off-list ref]; Shuah Khan [off-list ref]; Michal
Kubecek [off-list ref]; Florian Fainelli [off-list ref];
Andrew Lunn [off-list ref]; Rui Sousa [off-list ref]; Sebastien
Laveze [off-list ref]
Subject: Re: [net-next, v3, 05/10] ethtool: add a new command for getting PHC
virtual clocks
On Tue, 15 Jun 2021 17:45:12 +0800 Yangbo Lu wrote:
quoted
Add an interface for getting PHC (PTP Hardware Clock) virtual clocks,
which are based on PHC physical clock providing hardware timestamp to
network packets.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
quoted
diff --git a/include/uapi/linux/ethtool.h
b/include/uapi/linux/ethtool.h index cfef6b08169a..0fb04f945767 100644
-----Original Message-----
From: Mat Martineau <redacted>
Sent: 2021年6月16日 9:01
To: Y.b. Lu <yangbo.lu@nxp.com>
Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-kselftest@vger.kernel.org; mptcp@lists.linux.dev; Richard Cochran
[off-list ref]; David S . Miller [off-list ref];
Jakub Kicinski [off-list ref]; Matthieu Baerts
[off-list ref]; Shuah Khan [off-list ref]; Michal
Kubecek [off-list ref]; Florian Fainelli [off-list ref];
Andrew Lunn [off-list ref]; Rui Sousa [off-list ref]; Sebastien
Laveze [off-list ref]; Florian Westphal [off-list ref]
Subject: Re: [net-next, v3, 07/10] net: sock: extend SO_TIMESTAMPING for
PHC binding
On Tue, 15 Jun 2021, Yangbo Lu wrote:
quoted
Since PTP virtual clock support is added, there can be several PTP
virtual clocks based on one PTP physical clock for timestamping.
This patch is to extend SO_TIMESTAMPING API to support PHC (PTP
Hardware Clock) binding by adding a new flag
SOF_TIMESTAMPING_BIND_PHC. When PTP virtual clocks are in use, user
space can configure to bind one for timestamping, but PTP physical
clock is not supported and not needed to bind.
This patch is preparation for timestamp conversion from raw timestamp
to a specific PTP virtual clock time in core net.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
Changes for v3:
- Added this patch.
---
include/net/sock.h | 8 +++-
include/uapi/linux/net_tstamp.h | 17 ++++++++-
net/core/sock.c | 65
mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnam
quoted
break;
case SO_TIMESTAMPING_NEW:
case SO_TIMESTAMPING_OLD:
- sock_set_timestamping(sk, optname, val);
+ sock_set_timestamping(sk, optname, val, optval, optlen);
This is inside a loop, so in cases where optlen == sizeof(struct
so_timestamping) this will end up re-copying the structure from userspace
one extra time for each MPTCP subflow: once for the MPTCP socket, plus one
time for each of the TCP subflows that are grouped under this MPTCP
connection.
Given that the extra copies only happen when using the extended bind_phc
option, it's not a huge cost. But sock_set_timestamping() was written to
avoid the extra copies for 'int' sized options, and if that was worth the
effort then the larger so_timestamping structure could be copied (once)
before the sock_set_timestamping() call and passed in.
I see now...
Let me pass so_timestamping structure in to avoid re-copying from userspace.
quoted
break;
}
@@ -207,7 +210,8 @@ static int mptcp_setsockopt_sol_socket_int(struct
mptcp_sock *msk, int optname,
quoted
case SO_TIMESTAMPNS_NEW:
case SO_TIMESTAMPING_OLD:
case SO_TIMESTAMPING_NEW:
- return mptcp_setsockopt_sol_socket_tstamp(msk, optname, val);
+ return mptcp_setsockopt_sol_socket_tstamp(msk, optname, val,
+ optval, optlen);
Rather than modifying mptcp_setsockopt_sol_socket_int(), I suggest adding
a mptcp_setsockopt_sol_socket_timestamping() helper function that can
handle the special copying for so_timestamping.
Can we please have a kthread worker here instead of work?
Experience shows that plain work can be delayed for a long, long time on busy
systems.
I think do_aux_work callback could be utilized for ptp virtual clock, right?
quoted
+};
+
/*
* The function queue_cnt() is safe for readers to call without
* holding q->lock. Readers use this function to verify that the
queue @@ -89,4 +103,6 @@ extern const struct attribute_group
*ptp_groups[]; int ptp_populate_pin_groups(struct ptp_clock *ptp);
void ptp_cleanup_pin_groups(struct ptp_clock *ptp);
+struct ptp_vclock *ptp_vclock_register(struct ptp_clock *pclock);
+void ptp_vclock_unregister(struct ptp_vclock *vclock);
#endif
quoted
diff --git a/drivers/ptp/ptp_vclock.c b/drivers/ptp/ptp_vclock.c new
the similarity of naming is confusing for these two. They are only used in
the .adjfine method. How about this?
PTP_VCLOCK_FADJ_NUMERATOR, or even PTP_VCLOCK_FADJ_SHIFT (see
below)
PTP_VCLOCK_FADJ_DENOMINATOR
quoted
+#define PTP_VCLOCK_CC_REFRESH_INTERVAL (HZ * 2)
Consider dropping CC from the name.
PTP_VCLOCK_REFRESH_INTERVAL sounds good to me.
Thanks. Will rename the MACROs per your suggestion.
quoted
+static int ptp_vclock_adjfine(struct ptp_clock_info *ptp, long
+scaled_ppm) {
+ struct ptp_vclock *vclock = info_to_vclock(ptp);
+ unsigned long flags;
+ s64 adj;
+
+ adj = (s64)scaled_ppm * PTP_VCLOCK_CC_MULT_NUM;
Rather than
scaled_ppm * (1 << 9)
I suggest
scaled_ppm << 9
instead. I suppose a good compiler would replace the multiplication with a
bit shift, but it never hurts to spell it out.
@@ -61,6 +61,19 @@ Description: This file contains the number of programmable pins offered by the PTP hardware clock.+What: /sys/class/ptp/ptpN/n_vclocks+Date: May 2021+Contact: Yangbo Lu <yangbo.lu@nxp.com>+Description:+ This file contains the ptp virtual clocks number in use,+ based on current ptp physical clock. In default, the+ value is 0 meaning only ptp physical clock is in use.+ Setting the value can create corresponding number of ptp+ virtual clocks to use. But current ptp physical clock is+ guaranteed to stay free running. Setting the value back+ to 0 can delete ptp virtual clocks and back use ptp+ physical clock again.
The native speaker in me suggests:
This file contains the number of virtual PTP clocks in
use. By default, the value is 0 meaning that only the
physical clock is in use. Setting the value creates
the corresponding number of virtual clocks and causes
the physical clock to become free running. Setting the
value back to 0 deletes the virtual clocks and
switches the physical clock back to normal, adjustable
operation.
Initially I think vclock can be used for ptp multiple domains synchronization. Since the PTP domainValue is u8, u8 vclock number is large enough.
This is not a good idea to hard-code a PTP_MAX_VCLOCKS value. But it looks a little crazy to create numbers of vclocks via one command (echo n > /sys/class/ptp/ptp0/n_vclocks).
Maybe a typo creates hundreds of vclocks we don’t need.
Do you think we should be care about setting a limitation of vclock number? Any suggestion for implementation?
Thanks.
This is good: ^^^^^^^^^^^^^^^^^^^^^^^^^
You can drop this part:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
So, please rename ptp_guaranteed_pclock() to ptp_vclock_in_use();
-----Original Message-----
From: Y.b. Lu
Sent: 2021年6月22日 18:35
To: Richard Cochran <richardcochran@gmail.com>
Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-kselftest@vger.kernel.org; mptcp@lists.linux.dev; David S . Miller
[off-list ref]; Jakub Kicinski [off-list ref]; Mat Martineau
[off-list ref]; Matthieu Baerts
[off-list ref]; Shuah Khan [off-list ref]; Michal
Kubecek [off-list ref]; Florian Fainelli [off-list ref];
Andrew Lunn [off-list ref]; Rui Sousa [off-list ref]; Sebastien
Laveze [off-list ref]
Subject: RE: [net-next, v3, 02/10] ptp: support ptp physical/virtual clocks
conversion
Hi Richard,
quoted
-----Original Message-----
From: Richard Cochran <richardcochran@gmail.com>
Sent: 2021年6月18日 2:28
To: Y.b. Lu <yangbo.lu@nxp.com>
Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-kselftest@vger.kernel.org; mptcp@lists.linux.dev; David S .
Miller [off-list ref]; Jakub Kicinski [off-list ref]; Mat
Martineau [off-list ref]; Matthieu Baerts
[off-list ref]; Shuah Khan [off-list ref]; Michal
Kubecek [off-list ref]; Florian Fainelli [off-list ref];
Andrew Lunn [off-list ref]; Rui Sousa [off-list ref];
Sebastien
quoted
Laveze [off-list ref]
Subject: Re: [net-next, v3, 02/10] ptp: support ptp physical/virtual
clocks conversion
On Tue, Jun 15, 2021 at 05:45:09PM +0800, Yangbo Lu wrote:
Initially I think vclock can be used for ptp multiple domains synchronization.
Since the PTP domainValue is u8, u8 vclock number is large enough.
This is not a good idea to hard-code a PTP_MAX_VCLOCKS value. But it looks a
little crazy to create numbers of vclocks via one command (echo n >
/sys/class/ptp/ptp0/n_vclocks).
Maybe a typo creates hundreds of vclocks we don’t need.
Do you think we should be care about setting a limitation of vclock number?
Any suggestion for implementation?
Thanks.
I sent v4. I removed the u8 limitation for vclocks number, using unsigned int instead.
I introduced max_vclocks attribute which could be re-configured.
Please help to review.
Thanks.