[Linuxptp-devel] [PTPBASE-MIB 3/3] snmp4lptp: Added PTPBASE_MIB logic to snmp agent

2018-09-13 Thread Anders Selhammer
Signed-off-by: Anders Selhammer 
---
 snmp4lptp.c | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/snmp4lptp.c b/snmp4lptp.c
index c70aefa..50426cc 100644
--- a/snmp4lptp.c
+++ b/snmp4lptp.c
@@ -31,8 +31,13 @@
 #include "util.h"
 
 #define SNMP_NFD 1
+
 static struct pmc *pmc;
 
+struct snmp_mibs {
+   void *ptpbase;
+};
+
 struct ptp_message* snmp4lptp_run_pmc(char *cmd)
 {
struct pollfd pollfd[SNMP_NFD];
@@ -83,18 +88,29 @@ static int open_pmc(struct config *cfg)
return pmc ? 0 : -1;
 }
 
-static int open_snmp()
+static int open_snmp(struct snmp_mibs *mibs)
 {
snmp_enable_calllog();
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
   NETSNMP_DS_AGENT_ROLE, 1);
init_agent("linuxptpAgent");
 
+   if (init_ptpbase_mib(mibs->ptpbase)) {
+   return -1;
+   }
+
init_snmp("linuxptpAgent");
 
return 0;
 }
 
+static void free_snmp_mibs(struct snmp_mibs *mibs)
+{
+   if (mibs->ptpbase) {
+   free_ptpbase_mib(mibs->ptpbase);
+   }
+}
+
 static void usage(char *progname)
 {
fprintf(stderr,
@@ -110,6 +126,7 @@ static void usage(char *progname)
 int main(int argc, char *argv[])
 {
char *config = NULL, *progname;
+   struct snmp_mibs mibs = {0};
int c, err = 0, index;
struct option *opts;
struct config *cfg;
@@ -176,7 +193,7 @@ int main(int argc, char *argv[])
goto pmc_out;
}
 
-   if (open_snmp()) {
+   if (open_snmp(&mibs)) {
err = -1;
goto snmp_out;
}
@@ -188,6 +205,7 @@ int main(int argc, char *argv[])
snmp_shutdown("linuxptpAgent");
 
 snmp_out:
+free_snmp_mibs(&mibs);
pmc_destroy(pmc);
msg_cleanup();
 pmc_out:
-- 
1.8.3.1



___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PTPBASE-MIB 1/3] snmp4lptp: Added function for retrieval of current domain number

2018-09-13 Thread Anders Selhammer
Signed-off-by: Anders Selhammer 
---
 pmc_common.c| 5 +
 pmc_common.h| 2 ++
 snmp4lptp.c | 5 +
 snmp4lptp_mib.h | 1 +
 4 files changed, 13 insertions(+)

diff --git a/pmc_common.c b/pmc_common.c
index 4a160f6..b5843b9 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -479,6 +479,11 @@ static int pmc_tlv_datalen(struct pmc *pmc, int id)
return len;
 }
 
+UInteger8 pmc_get_domain_number(struct pmc *pmc)
+{
+   return pmc->domain_number;
+}
+
 int pmc_get_transport_fd(struct pmc *pmc)
 {
return pmc->fdarray.fd[FD_GENERAL];
diff --git a/pmc_common.h b/pmc_common.h
index b1fdcd6..8952151 100644
--- a/pmc_common.h
+++ b/pmc_common.h
@@ -40,6 +40,8 @@ struct pmc *pmc_create(struct config *cfg, enum 
transport_type transport_type,
 
 void pmc_destroy(struct pmc *pmc);
 
+UInteger8 pmc_get_domain_number(struct pmc *pmc);
+
 int pmc_get_transport_fd(struct pmc *pmc);
 
 int pmc_send_get_action(struct pmc *pmc, int id);
diff --git a/snmp4lptp.c b/snmp4lptp.c
index e06f212..c70aefa 100644
--- a/snmp4lptp.c
+++ b/snmp4lptp.c
@@ -65,6 +65,11 @@ struct ptp_message* snmp4lptp_run_pmc(char *cmd)
return NULL;
 }
 
+uint8_t snmp4lptp_get_domain()
+{
+   return pmc_get_domain_number(pmc);
+}
+
 static int open_pmc(struct config *cfg)
 {
char uds_local[MAX_IFNAME_SIZE + 1];
diff --git a/snmp4lptp_mib.h b/snmp4lptp_mib.h
index f135006..af449ce 100644
--- a/snmp4lptp_mib.h
+++ b/snmp4lptp_mib.h
@@ -26,5 +26,6 @@
  * function declarations
  */
 struct ptp_message* snmp4lptp_run_pmc(char *cmd);
+uint8_t snmp4lptp_get_domain();
 
 #endif /* HAVE_SNMP4LPTP_MIB_H */
-- 
1.8.3.1



___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PTPBASE-MIB 0/3] Partial support of PTPBASE-MIB

2018-09-13 Thread Anders Selhammer
This series adds the support for the implemented data sets in ptp4l
described in PTPBASE-MIB.
The snmp4lptp is used as a subagent to netsnamp master agent. The
infrmation is collected directly from ptp4l program using the uds
port.

Anders Selhammer (3):
  snmp4lptp: Added function for retrieval of current domain number
  Introduce logic for supported ds in PTPBASE_MIB
  snmp4lptp: Added PTPBASE_MIB logic to snmp agent

 makefile|   6 +-
 pmc_common.c|   5 +
 pmc_common.h|   2 +
 ptpbase_mib.c   | 898 
 snmp4lptp.c |  27 +-
 snmp4lptp_mib.h |   4 +
 6 files changed, 937 insertions(+), 5 deletions(-)
 create mode 100644 ptpbase_mib.c

-- 
1.8.3.1



___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


[Linuxptp-devel] [PTPBASE-MIB 2/3] Introduce logic for supported ds in PTPBASE_MIB

2018-09-13 Thread Anders Selhammer
This patch intruduces the supported ds described in PTPBASE_MIB. The
rest of the unsupported ds are not covered. These ds needs to be added
in ptp4l to begin with.

Signed-off-by: Anders Selhammer 
---
 makefile|   6 +-
 ptpbase_mib.c   | 898 
 snmp4lptp_mib.h |   3 +
 3 files changed, 904 insertions(+), 3 deletions(-)
 create mode 100644 ptpbase_mib.c

diff --git a/makefile b/makefile
index 6995e70..3f21001 100644
--- a/makefile
+++ b/makefile
@@ -40,7 +40,7 @@ version := $(shell $(srcdir)/version.sh $(srcdir))
 VPATH  = $(srcdir)
 
 ifneq (,$(findstring -DHAVE_NET_SNMP,$(snmpflg)))
-PRG+= snmp4lptp
+PRG+= snmp4lptp ptpbase_mib.o
 OBJECTS+= snmp4lptp.o
 snmplib:= $(shell net-snmp-config --netsnmp-agent-libs)
 endif
@@ -68,8 +68,8 @@ hwstamp_ctl: hwstamp_ctl.o version.o
 
 phc_ctl: phc_ctl.o phc.o sk.o util.o clockadj.o sysoff.o print.o version.o
 
-snmp4lptp: config.o hash.o msg.o pmc_common.o print.o raw.o sk.o \
- snmp4lptp.o tlv.o transport.o udp.o udp6.o uds.o util.o
+snmp4lptp: config.o hash.o msg.o pmc_common.o print.o ptpbase_mib.o raw.o \
+ sk.o snmp4lptp.o tlv.o transport.o udp.o udp6.o uds.o util.o
$(CC) $^ $(LDFLAGS) $(LOADLIBES) $(LDLIBS) $(snmplib) -o $@
 
 snmp4lptp.o: snmp4lptp.c
diff --git a/ptpbase_mib.c b/ptpbase_mib.c
new file mode 100644
index 000..cd39274
--- /dev/null
+++ b/ptpbase_mib.c
@@ -0,0 +1,898 @@
+/**
+ * @file ptpbase_mib.c
+ * @brief Implements PTPv2 Management Information Base (RFC 8173)
+ * @note Copyright (C) 2018 Anders Selhammer 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#include 
+#include 
+#include 
+
+#include "clock.h"
+#include "ds.h"
+#include "pdt.h"
+#include "print.h"
+#include "snmp4lptp_mib.h"
+#include "tlv.h"
+#include "tmv.h"
+
+/*
+ * ptp base oid values
+ */
+#define SNMP_OID_PTPBASE_MIB  1, 3, 6, 1, 2, 1, 241
+#define SNMP_OID_PTPBASE_OBJ_CLOCKINFOSNMP_OID_PTPBASE_MIB, 1, 2
+#define SNMP_OID_PTPBASE_CLOCK_CDSSNMP_OID_PTPBASE_OBJ_CLOCKINFO, 1
+#define SNMP_OID_PTPBASE_CLOCK_PDSSNMP_OID_PTPBASE_OBJ_CLOCKINFO, 2
+#define SNMP_OID_PTPBASE_CLOCK_DDSSNMP_OID_PTPBASE_OBJ_CLOCKINFO, 3
+#define SNMP_OID_PTPBASE_CLOCK_TDSSNMP_OID_PTPBASE_OBJ_CLOCKINFO, 5
+#define SNMP_OID_PTPBASE_PORT_DS  SNMP_OID_PTPBASE_OBJ_CLOCKINFO, 8
+
+/*
+ * column number definitions for tables
+ */
+
+#define COLUMN_CURRENTDS_STEPSREMOVED   4
+#define COLUMN_CURRENTDS_OFFSETFROMMASTER   5
+#define COLUMN_CURRENTDS_MEANPATHDELAY  6
+#define COLUMN_CDS_MIN COLUMN_CURRENTDS_STEPSREMOVED
+#define COLUMN_CDS_MAX COLUMN_CURRENTDS_MEANPATHDELAY
+
+#define COLUMN_PARENTDS_PARENTPORTIDENTITY  4
+#define COLUMN_PARENTDS_PARENTSTATS 5
+#define COLUMN_PARENTDS_OFFSET  6
+#define COLUMN_PARENTDS_CLOCKPHCHRATE   7
+#define COLUMN_PARENTDS_GMCLOCKIDENTITY 8
+#define COLUMN_PARENTDS_GMCLOCKPRIORITY19
+#define COLUMN_PARENTDS_GMCLOCKPRIORITY210
+#define COLUMN_PARENTDS_GMCLOCKQUALITYCLASS 11
+#define COLUMN_PARENTDS_GMCLOCKQUALITYACCURACY  12
+#define COLUMN_PARENTDS_GMCLOCKQUALITYOFFSET13
+#define COLUMN_PDS_MIN COLUMN_PARENTDS_PARENTPORTIDENTITY
+#define COLUMN_PDS_MAX COLUMN_PARENTDS_GMCLOCKQUALITYOFFSET
+
+#define COLUMN_DEFAULTDS_TWOSTEPFLAG4
+#define COLUMN_DEFAULTDS_CLOCKIDENTITY  5
+#define COLUMN_DEFAULTDS_PRIORITY1  6
+#define COLUMN_DEFAULTDS_PRIORITY2  7
+#define COLUMN_DEFAULTDS_SLAVEONLY  8
+#define COLUMN_DEFAULTDS_QUALITYCLASS   9
+#define COLUMN_DEFAULTDS_QUALITYACCURACY10
+#define COLUMN_DEFAULTDS_QUALITYOFFSET  11
+#define COLUMN_DDS_MIN COLUMN_DEFAULTDS_TWOSTEPFLAG
+#define COLUMN_DDS_MAX COLUMN_DEFAULTDS_QUALITYOFFSET
+
+#define COLUMN_TIMEPROPERTIESDS_CURRENTUTCOFFSETVALID   4
+#define COLUMN_TIMEPROPERTIESDS_

Re: [Linuxptp-devel] [PATCH 1/1] Add possibility to set clockIdentity

2018-09-13 Thread Anders Selhammer
Wednesday, September 12, 2018 8:33 PM

> Can you please explain the use case in detail?

If the ptpstack is started with a set of ports and during operational time 
ports are added and removed.
If the stack by some reason is restarted, the clockIdentity needs to be the 
same even if the port that generated the
first clockIdentity is no longer configured in the stack. The generate function 
does not make sure of that.


Wednesday, September 12, 2018 3:07 AM

> Man page updates? And it should probably make sure that if the clock identify 
> is all 0s we will autogenerate it.

Yes, manpage should also be updated. 
And there is a check for all 0s, do you want the check in another way?

> + if (strcmp(config_get_string(config, NULL, "clockIdentity"),
> +"00..00") == 0) {
> + if (generate_clock_identity(&c->dds.clockIdentity,
> + iface->name)) {
> + pr_err("failed to generate a clock identity");
> + return NULL;
> + }
> + } else {
> + if (str2cid(config_get_string(config, NULL, "clockIdentity"),
> +   &c->dds.clockIdentity)) {
> + pr_err("failed to set clock identity");
> + return NULL;
> + }

/anders


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH 1/1] G8275 - maxStepsRemoved

2018-09-13 Thread Richard Cochran
On Thu, Sep 13, 2018 at 06:24:30AM +, Anders Selhammer wrote:
> It is optional but not useless. It is easy implemented and has no big impact
> on the complexity of the system. It is used by Ericsson and it would be
> appreciated if the extra patch for this can be removed in the future.

Alright, you talked me into it.

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH 1/1] Add possibility to set clockIdentity

2018-09-13 Thread Richard Cochran
On Thu, Sep 13, 2018 at 06:18:15AM +, Anders Selhammer wrote:
> If the ptpstack is started with a set of ports and during operational time 
> ports are added and removed.
> If the stack by some reason is restarted, the clockIdentity needs to be the 
> same even if the port that generated the
> first clockIdentity is no longer configured in the stack. The generate 
> function does not make sure of that.

Thanks for the explanation.

Wouldn't it make more sense to allow adding ports on-the-fly?

The code is ready for this (or at least, someone did the ground work a
few years ago).

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH v1 0/6] Adding support for Automotive Profile

2018-09-13 Thread Patel, Vedang
Hi Richard,

Is this series somewhere in your list of "things to review"? I just
wanted to check-in and make sure you didnt miss this. 

Thanks,
Vedang

On Thu, 2018-08-30 at 16:54 -0700, Vedang Patel wrote:
> Changes in this version:
> ~~~
> 
> Since the series has gone through some feedback and is mature now, it
> is being
> posted as PATCH series instead of RFC.
> 
> This version incorporates feedback from the last version of this
> series. The
> changes include: 
> - Remove AVnu keyword from all commit messages.
> - Instead of adding special checks for BMCA == ‘noop’ in
> port_p2p_transtion, we
>   now transition to PS_LISTENING before going to PS_MASTER/PS_SLAVE
> for
>   designated master or slave.
> - designated_{master/slave}_fsm() functions were moved to their own
> file.
> - Minor change in check_source_identity function.
> - In all the series adds functionality from Sections 6.2.1.1 and
> Section 6.3
>   (pts #1 and #2) of the Automotive Profile[1].
> 
> More information of intention of this and future series at: 
> https://sourceforge.net/p/linuxptp/mailman/message/36369408/
> 
> Thanks,
> Vedang Patel
> 
> [1] Automotive Ethernet AVB Functional and Interoperability
> Specification -
> http://avnu.org/wp-content/uploads/2014/05/
> Automotive-Ethernet-AVB-Func-Interop-Spec-v1.5-Public.pdf
> 
> Vedang Patel (6):
>   port: Add condition to check fc.
>   clock: Add NULL check for best clock in clock_update_slave()
>   Add BMCA config option.
>   Add inhibit_announce config option.
>   Add ignore_source_id config option.
>   Add example configuration for Automotive Profile.
> 
>  bmc.c |  11 
>  clock.c   |  24 +++-
>  config.c  |   9 +++
>  configs/automotive-master.cfg |  27 +
>  configs/automotive-slave.cfg  |  30 ++
>  configs/default.cfg   |   3 +
>  designated_fsm.c  | 133
> ++
>  designated_fsm.h  |  43 ++
>  fsm.h |   6 +-
>  makefile  |  11 ++--
>  port.c|  63 
>  port.h|   8 +++
>  port_private.h|   3 +
>  ptp4l.8   |  31 --
>  14 files changed, 381 insertions(+), 21 deletions(-)
>  create mode 100644 configs/automotive-master.cfg
>  create mode 100644 configs/automotive-slave.cfg
>  create mode 100644 designated_fsm.c
>  create mode 100644 designated_fsm.h
> 
___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH 1/1] Add possibility to set clockIdentity

2018-09-13 Thread Keller, Jacob E
> -Original Message-
> From: Anders Selhammer [mailto:anders.selham...@est.tech]
> Sent: Wednesday, September 12, 2018 11:18 PM
> To: Richard Cochran 
> Cc: linuxptp-devel@lists.sourceforge.net
> Subject: Re: [Linuxptp-devel] [PATCH 1/1] Add possibility to set clockIdentity
> 
> > Man page updates? And it should probably make sure that if the clock 
> > identify
> is all 0s we will autogenerate it.
> 
> Yes, manpage should also be updated.
> And there is a check for all 0s, do you want the check in another way?
> 

Just make sure it's documented that all 00s in the config will autogenerate it.

Thanks,
Jake



___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH v1 0/6] Adding support for Automotive Profile

2018-09-13 Thread Richard Cochran
On Thu, Sep 13, 2018 at 04:29:21PM +, Patel, Vedang wrote:
> Is this series somewhere in your list of "things to review"? I just
> wanted to check-in and make sure you didnt miss this.

Yes, I'll get to it as soon as I can.  Overall I'm happy with this
series, but I wanted to sit down and think through the automatic
switch to MASTER state that we discussed.  Maybe next week...

Thanks,
Richard


___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel


Re: [Linuxptp-devel] [PATCH] add report of PTP_SYS_OFFSET_PRECISE support to phc_ctl

2018-09-13 Thread Richard Cochran
On Thu, Aug 16, 2018 at 03:22:51PM +, FUSTE Emmanuel wrote:
> diff --git a/phc_ctl.c b/phc_ctl.c
> index 4a78a19..f6234da 100644
> --- a/phc_ctl.c
> +++ b/phc_ctl.c
> @@ -353,12 +353,14 @@ static int do_caps(clockid_t clkid, int cmdc, char 
> *cmdv[])
>   "  %d programable alarms\n"
>   "  %d external time stamp channels\n"
>   "  %d programmable periodic signals\n"
> - "  %s pulse per second support",
> + "  %s pulse per second support\n"
> + "  %s precise system-device cross timestamps support",
>   caps.max_adj,
>   caps.n_alarm,
>   caps.n_ext_ts,
>   caps.n_per_out,
> - caps.pps ? "has" : "doesn't have");
> + caps.pps ? "has" : "doesn't have",
> + caps.cross_timestamping ? "has" : "doesn't have");
>   return 0;
>  }

This will need a compile time check for PTP_SYS_OFFSET_PRECISE, otherwise you 
get

/home/richard/git/linuxptp/phc_ctl.c: In function 'do_caps':
/home/richard/git/linuxptp/phc_ctl.c:350:2: error: 'struct ptp_clock_caps' has 
no member named 'cross_timestamping'
make: *** [phc_ctl.o] Error 1
make: *** Waiting for unfinished jobs
richard@hoboy:~/git/linuxptp$ uname -a
Linux hoboy 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u4 (2018-08-21) x86_64 
GNU/Linux

Thanks,
Richard



___
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel