Commit Graph

39 Commits (master)

Author SHA1 Message Date
Vladimir Oltean f44b3d8b6c phc2sys: break out pmc code into pmc_common.c
The code through which phc2sys sends various PTP management messages to
ptp4l via pmc can be reused.

This patch is a trivial movement of that code to a separate translation
module, outside of phc2sys. This makes it available to other programs
that want to subscribe to port state change events too, such as ts2phc.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
2020-08-30 01:48:48 +03:00
Richard Cochran 6c5b61a64c pmc: Support getting and setting the local synchronization uncertain flag.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2020-05-24 12:02:49 -07:00
Richard Cochran 2f0bfb2837 pmc: Allow multiple local subscribers.
If more than one local UDS client subscribes to push notifications,
only the last one receives data from the ptp4l service.  This happens
because ptp4l uses the PortIdentity as a unique key to track client
subscriptions.  As a result, it is not possible for both phc2sys and
pmc to receive push notifications at the same time, for example.

This patch sets the PortIdentity.portNumber attribute of UDS clients
to the local process ID, making each such client subscription unique.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2020-04-03 07:11:42 -07:00
Richard Cochran 1044268e85 pmc: Subscribe to port state push notification events when requested.
Allow interactive input like

    set SUBSCRIBE_EVENTS_NP duration 60 NOTIFY_PORT_STATE on

to request push notifications from the ptp4l service.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2020-04-03 07:04:31 -07:00
Richard Cochran aed79c38d4 pmc: Move private macros back into their source files.
The header file, pmc_common.h, makes some private macros public.  The
intent was to use those macros in SNMP code, but that development never
materialized into production code.  This patch removes the private macros
from public view.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2020-03-31 15:03:41 -07:00
Richard Cochran 66dc3167e3 pmc: Use the proper create/destroy API for network interfaces.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
2020-03-04 09:46:38 -08:00
Richard Cochran d471a57aa8 Convert call sites to the proper method for setting the name.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
2020-03-04 09:45:51 -08:00
Richard Cochran a8df585e04 Convert call sites to the proper method for initializing the time stamping label.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
2020-03-04 09:45:43 -08:00
Richard Cochran 34945679fe Convert call sites to the proper method for getting interface names.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2020-03-04 09:45:10 -08:00
Petr Machata 7985634179 pmc: Support querying TLV_PORT_PROPERTIES_NP
TLV_PORT_PROPERTIES_NP messages serve for querying of port properties, such
as timestamp type and, prominently, netdevice name associated with the
port. pmc however does not support this query, which makes it difficult to
access this information e.g. from scripts. Add this support to pmc.

Signed-off-by: Mykola Zhuravel <mykola@mellanox.com>
Signed-off-by: Petr Machata <petrm@mellanox.com>
2019-10-12 19:42:42 -07:00
Petr Machata 2b5bec8d27 pmc: Add a new TLV to obtain per-port statistics
Add an ability of pmc to query per-port stats added in the previous patch.

Signed-off-by: Petr Machata <petrm@mellanox.com>
2019-09-10 20:56:30 -07:00
Miroslav Lichvar 86723cfc6a pmc: Don't leak memory when msg_tlv_append() fails.
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2019-03-25 06:25:07 -07:00
Andriy Kohut f977a653e0 pmc_common: Recycle message if allocation of tlv_extra failed
Change-Id: I4ed12f1cddcb85e8f55552ce8980a9d5f3f7d800
Signed-off-by: Andriy Kohut <andriyk@mellanox.com>
2018-07-19 10:31:06 -07:00
Anders Selhammer d85c592993 pmc: Move new common funtionality into pmc_common
Code from pmc.c will be reused by new snmpd.c in later commit.

Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2018-07-05 23:17:32 -07:00
Richard Cochran 7a76c36b34 nsm, pmc: Check for missing HW time stamps.
As of 510777deca message layer no longer returns -ETIME.  Callers of
msg_post_recv() are expected to check for missing time stamps themselves.
This patch updates the two forgotten call sites.

Fixes: 510777deca ("msg: Move the check for missing HW time stamps into caller.")

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-18 18:44:28 -07:00
Richard Cochran a1c5e3f2ed transport: Fix callers to pass a proper enumeration value.
The majority of the callers of transport_send() use hard coded magic
numbers.  This patch fixes them to use the corresponding enumerated
values instead.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-13 22:29:05 -07:00
Richard Cochran d465406106 pmc: Initialize variable on the stack.
Valgrind is complaining that the pmc program is using uninitialized
data.  Actually the data are partially initialized, but it can't hurt
to zero the entire data structure.  Doing so silences the valgrind
warning, and after all it is good practice.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-30 10:29:30 -07:00
Peter Schneider ea9dda30e2 pmc_common: Preset uninitialized 'iface.ts_label' with 'iface.name'
pmc_create() calls transport_create(), which sets the open function
for the interface 'iface' to raw_open(), if Layer 2 is used. The
immediate following call of transport_open() calls raw_open(), which
uses the field .ts_label for opening, instead of the field .name
(which is used in the other transport layers). Therefore, the
field .name is copied here into the field .ts_label .

[ RC - Actually ts_label should always be initialized. Made the
       assignment of ts_label unconditional, regardless of the choice
       of transport layer. ]

Signed-off-by: Peter Schneider <peter@psch.de>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-24 21:14:35 -07:00
Richard Cochran e09d3a4aea pmc: Remove unused parameter.
The third parameter of the function, pmc_send(), is never used.  This patch
removes it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran b6fa8e20ee pmc: Convert to the API for appending TLVs on the transmit path.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran 7fe69e7ba0 msg: Populate the TLV list on receive.
This patch changes the receive message parsing code to place each TLV
into the list.  A method is introduced that allows attaching TLVs to
the end of the list.

In addition, msg.last_tlv is converted into a pointer to the last item
in the list.  Because of this change, the transmit code that uses this
field now allocates a TLV before using it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran 8ecdedaa69 pmc: Add missing break in switch/case.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-06 06:37:54 -08:00
Hangbin Liu 8923bcdf64 transport: pass struct interface to transport_open
Pass struct interface so we can use ts_iface in HW filter.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
2017-10-14 05:34:18 -07:00
Richard Cochran 3189a7bc0a transport: store the configuration in the transport data structure.
This will allow modules to read out various user options.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-16 11:20:23 +02:00
Richard Cochran bbbc0cd451 pmc: require a configuration for creating a PMC instance.
In the near future, the transports will need to consult the configuration
database in order to obtain various options.  This patch also introduces
the idea of a configuration file into the phc2sys and pmc programs.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2015-08-16 11:20:23 +02:00
Miroslav Lichvar 70dd682349 Prefix TLV IDs.
To avoid conflicts in generic names add TLV_ prefix to all TLV IDs
defined in tlv.h.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2014-07-09 06:31:25 +02:00
Jiri Benc 48f6a31cc3 pmc_common: easy way to set port and broadcast target
Implement pmc_target_port to set a port number, leaving clock identity
unchanged, and pmc_target_all to set clock identity and port number to all
1's.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-06-12 11:35:45 +02:00
Jiri Benc 14742ef566 uds: don't output "Connection refused"
When phc2sys is started before ptp4l or it is interrupted before ptp4l has
a chance to reply to its query, the "uds: sendto failed: Connection refused"
message is output. This is not an interesting message.

Also, don't output the "failed to send message" error from pmc_send, as
all transports output errors in their send routine.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-05-03 13:56:57 +02:00
Jiri Benc bbe634d790 Let transport_recv/send/peer use ptp_message
The callers of those functions are all using ptp_message. As we're going to
return more information (the address), let those functions just fill in the
ptp_message fields directly.

Some minor reshuffling needed to prevent circular header dependencies.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-04-17 06:49:38 +02:00
Stephan Gatzka 110849d422 Make functions and structs dealing with string literals const correct.
This allows the compiler to check if someone writes into string
literals.

Signed-off-by: Stephan Gatzka <stephan.gatzka@gmail.com>
2014-02-07 19:41:47 +01:00
Delio Brignoli 29063a8227 pmc: support retrieving neighborPropDelayThresh and asCapable using management interface
Define new PORT_DATA_SET_NP TLV
neighborPropDelayThresh can also be set using the same TLV

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2014-02-04 18:59:26 +01:00
Richard Cochran 923ff5bbc1 pmc_common: introduce a variable for the target port identity.
This patch replaces the hard coded wild card target port identity with
a variable initially set to the wild card value. The intent is to allow
the caller to set specific targets.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-22 21:47:28 +02:00
Richard Cochran b0d789a73e pmc: optional legacy zero length TLV for GET actions.
This patch makes the original behavior of sending the
TLV values for GET actions with a length of zero.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-22 21:47:28 +02:00
Richard Cochran 0650b079f9 pmc: send GET management messages according to interpretation #29.
This commit makes the GET messages have data bodies, just like the erratum
says to. It really doesn't make sense, but have to do it anyhow. We also
introduce a variable that will enable the legacy behavior of sending
empty bodies.

   http://standards.ieee.org/findstds/interps/1588-2008.html

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-22 21:47:28 +02:00
Richard Cochran 4ae27d9179 pmc: make the TLV length a functional result.
This patch lets the TLV length field of GET messages come from a
function. For now, the function still results in a length of two,
but the intent is to allow different values later.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-22 21:47:27 +02:00
Richard Cochran 6a1a16ac66 pmc: add a utility function for sending a message with the SET action.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-07-14 21:37:52 +02:00
Libor Pechacek 0367bb5f1b Distinguish between ignored and malformed packets
When there is a peer speaking PTPv1 in the network we want to silently ignore
the packets instead of flooding system log with error messages.  At the same
time we still want to report malformed packets.  For that we reuse standard
error numbers and do more fine-grained error reporting in packet processing
routines.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
2013-03-28 18:48:52 +01:00
Geoff Salmon 5b8e169486 match pmc_send_get_action's definition and declaration
Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-09 08:38:20 +01:00
Miroslav Lichvar cbc1a70c2c Move some pmc code to separate file.
Move some code which can be shared between PTP management clients to
a new file.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
2013-02-03 19:08:34 +01:00