On Thu, 25 Aug 2022 at 07:59, Devasish Dey <devasish....@syncmonk.net> wrote:
> Hi Erez, > > Please find the answers inline. With the next version of patches, I will > add small details. > > Hi All, > > For detailed design and working of these features you can refer to: > > IWF: > https://www.linkedin.com/feed/update/urn:li:activity:6967393759600812032 > Virtual Port and APTS: > https://www.linkedin.com/feed/update/urn:li:activity:6963367173301960706 > > If we have some provision for documentation in LinuxPTP let us know if we > can contribute there as well. > Please like, share your views and follow us at > https://www.linkedin.com/company/syncmonk > <https://www.linkedin.com/company/syncmonk> > > Thanks, > Devasish Dey > SyncMonk Technologies. > > On Wed, 24 Aug 2022 at 19:21, Erez <erezge...@gmail.com> wrote: > >> >> >> On Wed, 24 Aug 2022 at 13:05, SyncMonk Technologies < >> servi...@syncmonk.net> wrote: >> >>> Adding virtual PTP port support >>> >> >> I understand what is a virtual clock, but what is a virtual port? >> A port on a VLAN? I thought linuxptp already handles VLANs. >> I do not expect you to replace or write the whole standart, but a short >> explanation of context. >> Perhaps an example of a usage. >> > [SyncMonk]: It is about special ports. > It was defined before 1588-2019 Special Port. There are similarities, but > not the same. > It describes how to connect synchronization network segments that are > running different PTP profiles. > Please give a simple description of 2 sentences, what is a virtual port. For example: "A virtual clock is a PTP clock that uses a software implementation to emulate a hardware PHC. For example: we use it in cases where we want to have multiple PTP domains in a single port, though the port only has a single hardware PHC." > >> As per G.8275 (Annex-B) including virtual PTP ports on a PTP clock. This >>> virtual port will be used to support APTS, IWF between different >>> clock_domains. >>> >> >> Please provide full text for new acronyms. >> In this patch description and once in the code. >> Not all of us know what "APTS" and "IWF" are. >> We may use these acronyms in a different place or context. >> > [SyncMonk]: We will add the acronyms with the next version of patch. > The reason behind adding the standards referred was they have the > abbreviation and acronyms sections. > APTS stands for Assisted Partial Time Support and is an option of the > G.8275.2 Profile. > IWF stands for Inter-Working Function and is defined in Appendix III of > G.8275. > Great, that is good. Yes, we can read the standard, if we have time. As you write the patch, you must. Expleaning new acronyms you use, does help read the patch and understand the context. Regardless of who created these acronyms. Last point, I think that if you mentioned the protocol G.8275 before, you do not have to repeat it. If we do read the standard, we would probably find the acronyms in the acronyms table. And we can use the table of context and the index table to find relevant sections. Erez > >> >>> >>> Signed-off-by: Greg Armstrong <greg.armstrong...@renesas.com> >>> Signed-off-by: Leon Goldin <leon.goldin...@renesas.com> >>> Signed-off-by: Vipin Sharma <vipin.sha...@syncmonk.net> >>> Signed-off-by: Devasish Dey <devasish....@syncmonk.net> >>> --- >>> makefile | 2 +- >>> vport.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ >>> vport.h | 20 ++++++++ >>> 3 files changed, 161 insertions(+), 1 deletion(-) >>> create mode 100644 vport.c >>> create mode 100644 vport.h >>> >>> diff --git a/makefile b/makefile >>> index 5295b60..7d8c0d3 100644 >>> --- a/makefile >>> +++ b/makefile >>> @@ -25,7 +25,7 @@ LDLIBS = -lm -lrt -pthread $(EXTRA_LDFLAGS) >>> PRG = ptp4l hwstamp_ctl nsm phc2sys phc_ctl pmc timemaster ts2phc >>> FILTERS = filter.o mave.o mmedian.o >>> SERVOS = linreg.o ntpshm.o nullf.o pi.o servo.o >>> -TRANSP = raw.o transport.o udp.o udp6.o uds.o >>> +TRANSP = raw.o transport.o udp.o udp6.o uds.o vport.o >>> TS2PHC = ts2phc.o lstab.o nmea.o serial.o sock.o >>> ts2phc_generic_pps_source.o \ >>> ts2phc_nmea_pps_source.o ts2phc_phc_pps_source.o ts2phc_pps_sink.o >>> ts2phc_pps_source.o >>> OBJ = bmc.o clock.o clockadj.o clockcheck.o config.o >>> designated_fsm.o \ >>> diff --git a/vport.c b/vport.c >>> new file mode 100644 >>> index 0000000..89d4105 >>> --- /dev/null >>> +++ b/vport.c >>> @@ -0,0 +1,140 @@ >>> +/** >>> + * @file vport.c >>> + * @note Copyright (C) 2022 SyncMonk Technologies < >>> servi...@syncmonk.net> >>> + * @note SPDX-License-Identifier: GPL-2.0+ >>> + * >>> + */ >>> +#include <errno.h> >>> +#include <stdio.h> >>> +#include <stdlib.h> >>> +#include <string.h> >>> +#include <sys/socket.h> >>> +#include <sys/stat.h> >>> +#include <sys/un.h> >>> +#include <unistd.h> >>> + >>> +#include "address.h" >>> +#include "contain.h" >>> +#include "print.h" >>> +#include "transport_private.h" >>> +#include "vport.h" >>> + >>> +#define VPORT_FILEMODE (0660) /*0660*/ >>> + >>> +struct vport { >>> + struct transport t; >>> + struct address address; >>> +}; >>> + >>> +static int vport_close(struct transport *t, struct fdarray *fda) >>> +{ >>> + struct sockaddr_un sa; >>> + socklen_t len = sizeof(sa); >>> + >>> + if (!getsockname(fda->fd[FD_GENERAL], >>> + (struct sockaddr *) &sa, &len) && >>> + sa.sun_family == AF_LOCAL) { >>> + unlink(sa.sun_path); >>> + } >>> + >>> + close(fda->fd[FD_GENERAL]); >>> + return 0; >>> +} >>> + >>> +static int vport_open(struct transport *t, >>> + struct interface *iface, >>> + struct fdarray *fda, >>> + enum timestamp_type tt) >>> +{ >>> + char *vport_path = config_get_string(t->cfg, NULL, >>> "vport_address"); >>> + struct vport *vport = container_of(t, struct vport, t); >>> + const char *name = interface_name(iface); >>> + struct sockaddr_un sa; >>> + int fd, err; >>> + >>> + fd = socket(AF_LOCAL, SOCK_DGRAM, 0); >>> + if (fd < 0) { >>> + pr_err("vport: failed to create socket: %m"); >>> + return -1; >>> + } >>> + memset(&sa, 0, sizeof(sa)); >>> + sa.sun_family = AF_LOCAL; >>> + strncpy(sa.sun_path, name, sizeof(sa.sun_path) - 1); >>> + >>> + unlink(name); >>> + >>> + err = bind(fd, (struct sockaddr *) &sa, sizeof(sa)); >>> + if (err < 0) { >>> + pr_err("vport: bind failed: %m"); >>> + close(fd); >>> + return -1; >>> + } >>> + >>> + /* For client use, pre load the server path. */ >>> + memset(&sa, 0, sizeof(sa)); >>> + sa.sun_family = AF_LOCAL; >>> + strncpy(sa.sun_path, vport_path, sizeof(sa.sun_path) - 1); >>> + vport->address.sun = sa; >>> + vport->address.len = sizeof(sa); >>> + >>> + chmod(name, VPORT_FILEMODE); >>> + fda->fd[FD_EVENT] = -1; >>> + fda->fd[FD_GENERAL] = fd; >>> + return 0; >>> +} >>> + >>> +static int vport_recv(struct transport *t, int fd, void *buf, int >>> buflen, >>> + struct address *addr, struct hw_timestamp *hwts) >>> +{ >>> + int cnt; >>> + struct vport *vport = container_of(t, struct vport, t); >>> + >>> + addr->len = sizeof(addr->sun); >>> + cnt = recvfrom(fd, buf, buflen, 0, &addr->sa, &addr->len); >>> + if (cnt <= 0) { >>> + pr_err("vport: recvfrom failed: %m"); >>> + return cnt; >>> + } >>> + vport->address = *addr; >>> + return cnt; >>> +} >>> + >>> +static int vport_send(struct transport *t, struct fdarray *fda, >>> + enum transport_event event, int peer, void *buf, >>> + int buflen, struct address *addr, >>> + struct hw_timestamp *hwts) >>> +{ >>> + int cnt, fd = fda->fd[FD_GENERAL]; >>> + struct vport *vport = container_of(t, struct vport, t); >>> + >>> + if (!addr) >>> + addr = &vport->address; >>> + >>> + cnt = sendto(fd, buf, buflen, 0, &addr->sa, addr->len); >>> + if (cnt < 1) { >>> + return -errno; >>> + } >>> + return cnt; >>> +} >>> + >>> +static void vport_release(struct transport *t) >>> +{ >>> + struct vport *vport = container_of(t, struct vport, t); >>> + >>> + free(vport); >>> +} >>> + >>> +struct transport *vport_transport_create(void) >>> +{ >>> + struct vport *vport; >>> + >>> + vport = calloc(1, sizeof(*vport)); >>> + if (!vport) >>> + return NULL; >>> + vport->t.close = vport_close; >>> + vport->t.open = vport_open; >>> + vport->t.recv = vport_recv; >>> + vport->t.send = vport_send; >>> + vport->t.release = vport_release; >>> + return &vport->t; >>> +} >>> diff --git a/vport.h b/vport.h >>> new file mode 100644 >>> index 0000000..a479fe7 >>> --- /dev/null >>> +++ b/vport.h >>> @@ -0,0 +1,20 @@ >>> +/** >>> + * @file vport.h >>> + * @note Copyright (C) 2022 SyncMonk Technologies < >>> servi...@syncmonk.net> >>> + * @note SPDX-License-Identifier: GPL-2.0+ >>> + * >>> + */ >>> +#ifndef HAVE_VPORT_H >>> +#define HAVE_VPORT_H >>> + >>> +#include "config.h" >>> +#include "fd.h" >>> +#include "transport.h" >>> + >>> +/** >>> + * Allocate an instance of a VPORT transport. >>> + * @return Pointer to a new transport instance on success, NULL >>> otherwise. >>> + */ >>> +struct transport *vport_transport_create(void); >>> + >>> +#endif >>> -- >>> 2.25.1 >>> >>> >>> >>> _______________________________________________ >>> Linuxptp-devel mailing list >>> Linuxptp-devel@lists.sourceforge.net >>> https://lists.sourceforge.net/lists/listinfo/linuxptp-devel >>> >> _______________________________________________ >> Linuxptp-devel mailing list >> Linuxptp-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/linuxptp-devel >> >
_______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel